source: flair-src/trunk/lib/FlairVisionFilter/src/Sobel.cpp@ 352

Last change on this file since 352 was 338, checked in by Sanahuja Guillaume, 5 years ago

remove opencv dep

File size: 3.3 KB
Line 
1// created: 2015/10/07
2// filename: Sobel.cpp
3//
4// author: Gildas Bayard
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: Sobel
10//
11//
12/*********************************************************************/
13
14#include "Sobel.h"
15#include "VisionFilter.h"
16#include <Image.h>
17#include <Layout.h>
18#include <GroupBox.h>
19#include <SpinBox.h>
20#include <typeinfo>
21
22using std::string;
23using namespace flair::core;
24using namespace flair::gui;
25
26class Sobel_impl {
27public:
28 Sobel_impl(flair::filter::Sobel *self,const LayoutPosition* position,string name):output(0) {
29 this->self=self;
30
31 GroupBox* reglages_groupbox=new GroupBox(position,name);
32 dx=new SpinBox(reglages_groupbox->NewRow(),"dx:",0,1,1,1);
33 dy=new SpinBox(reglages_groupbox->NewRow(),"dy:",0,1,1,1);
34
35 Printf("TODO: IODevice doit faire un check de GetInputDataType et GetOutputDataType\n");
36 //Image devrait accepter un type dans son constructeur pour construire un type identique
37 try{
38 Image::Type const &imageType=dynamic_cast<Image::Type const &>(((IODevice*)(self->Parent()))->GetOutputDataType());
39 if(imageType.GetFormat()==Image::Type::Format::Gray) {
40 output=new Image(self,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"sobel");
41 //inIplImage = (IplImage*)AllocFunction(sizeof(IplImage));
42 //outIplImage = (IplImage*)AllocFunction(sizeof(IplImage));
43 } else {
44 self->Err("input image is not gray\n");
45 }
46
47 } catch(std::bad_cast& bc) {
48 self->Err("io type mismatch\n");
49 }
50 }
51
52 ~Sobel_impl() {
53 //FreeFunction((char*)(inIplImage));
54 //FreeFunction((char*)(outIplImage));
55 }
56
57 void UpdateFrom(const io_data *data){
58 Image *image=(Image*)data;
59/*
60 data->GetMutex();
61 inIplImage->width=image->GetDataType().GetWidth();
62 inIplImage->height=image->GetDataType().GetHeight();
63 inIplImage->imageData=image->buffer;
64 inIplImage->imageSize=image->GetDataType().GetSize();
65
66 output->GetMutex();
67 outIplImage->width=output->GetDataType().GetWidth();
68 outIplImage->height=output->GetDataType().GetHeight();
69 outIplImage->imageData=output->buffer;
70 outIplImage->imageSize=output->GetDataType().GetSize();
71
72 dspSobel(inIplImage,outIplImage,dx->Value(),dy->Value());
73 output->ReleaseMutex();
74 data->ReleaseMutex();
75*/
76 output->SetDataTime(data->DataTime());
77
78 };
79
80 Image *output;
81
82private:
83 flair::filter::Sobel *self;
84 SpinBox *dx;
85 SpinBox *dy;
86 //IplImage *inIplImage,*outIplImage;
87};
88
89namespace flair { namespace filter {
90
91Sobel::Sobel(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name) {
92 pimpl_=new Sobel_impl(this,position,name);
93}
94
95Sobel::~Sobel(void) {
96 delete pimpl_;
97}
98
99Image* Sobel::Output(void) {
100 return pimpl_->output;
101}
102
103void Sobel::UpdateFrom(const io_data *data) {
104 pimpl_->UpdateFrom(data);
105 ProcessUpdate(pimpl_->output);
106}
107
108DataType const &Sobel::GetOutputDataType() const {
109 if(pimpl_->output!=NULL) {
110 return pimpl_->output->GetDataType();
111 } else {
112 return dummyType;
113 }
114}
115
116} // end namespace filter
117} // end namespace flair
Note: See TracBrowser for help on using the repository browser.