Changeset 325 in flair-src for branches/sanscv/lib/FlairVisionFilter/src/Sobel.cpp
- Timestamp:
- 08/28/19 16:12:11 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sanscv/lib/FlairVisionFilter/src/Sobel.cpp
r324 r325 13 13 14 14 #include "Sobel.h" 15 #include "VisionFilter.h" 15 16 #include <Image.h> 16 17 #include <Layout.h> 17 18 #include <GroupBox.h> 18 19 #include <SpinBox.h> 20 //#include <dspcv_gpp.h> 19 21 #include <typeinfo> 20 22 … … 23 25 using namespace flair::gui; 24 26 27 class Sobel_impl { 28 public: 29 Sobel_impl(flair::filter::Sobel *self,const LayoutPosition* position,string name):output(0) { 30 this->self=self; 31 32 GroupBox* reglages_groupbox=new GroupBox(position,name); 33 dx=new SpinBox(reglages_groupbox->NewRow(),"dx:",0,1,1,1); 34 dy=new SpinBox(reglages_groupbox->NewRow(),"dy:",0,1,1,1); 35 36 Printf("TODO: IODevice doit faire un check de GetInputDataType et GetOutputDataType\n"); 37 //Image devrait accepter un type dans son constructeur pour construire un type identique 38 try{ 39 Image::Type const &imageType=dynamic_cast<Image::Type const &>(((IODevice*)(self->Parent()))->GetOutputDataType()); 40 if(imageType.GetFormat()==Image::Type::Format::Gray) { 41 output=new Image(self,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"sobel"); 42 //inIplImage = (IplImage*)AllocFunction(sizeof(IplImage)); 43 //outIplImage = (IplImage*)AllocFunction(sizeof(IplImage)); 44 } else { 45 self->Err("input image is not gray\n"); 46 } 47 48 } catch(std::bad_cast& bc) { 49 self->Err("io type mismatch\n"); 50 } 51 } 52 53 ~Sobel_impl() { 54 //FreeFunction((char*)(inIplImage)); 55 //FreeFunction((char*)(outIplImage)); 56 } 57 58 void UpdateFrom(const io_data *data){ 59 Image *image=(Image*)data; 60 /* 61 data->GetMutex(); 62 inIplImage->width=image->GetDataType().GetWidth(); 63 inIplImage->height=image->GetDataType().GetHeight(); 64 inIplImage->imageData=image->buffer; 65 66 output->GetMutex(); 67 outIplImage->width=output->GetDataType().GetWidth(); 68 outIplImage->height=output->GetDataType().GetHeight(); 69 outIplImage->imageData=output->buffer; 70 71 dspSobel(inIplImage,outIplImage,dx->Value(),dy->Value()); 72 output->ReleaseMutex(); 73 data->ReleaseMutex(); 74 */ 75 output->SetDataTime(data->DataTime()); 76 77 }; 78 79 Image *output; 80 81 private: 82 flair::filter::Sobel *self; 83 SpinBox *dx; 84 SpinBox *dy; 85 //IplImage *inIplImage,*outIplImage; 86 }; 87 25 88 namespace flair { namespace filter { 26 89 27 Sobel::Sobel(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name),output(0) { 28 GroupBox* reglages_groupbox=new GroupBox(position,name); 29 dx=new SpinBox(reglages_groupbox->NewRow(),"dx:",0,1,1,1); 30 dy=new SpinBox(reglages_groupbox->NewRow(),"dy:",0,1,1,1); 31 32 Printf("TODO: IODevice doit faire un check de GetInputDataType et GetOutputDataType\n"); 33 //Image devrait accepter un type dans son constructeur pour construire un type identique 34 try{ 35 Image::Type const &imageType=dynamic_cast<Image::Type const &>(parent->GetOutputDataType()); 36 if(imageType.GetFormat()==Image::Type::Format::Gray) { 37 output=new Image(this,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"sobel"); 38 } else { 39 Err("input image is not gray\n"); 40 return; 41 } 42 43 } catch(std::bad_cast& bc) { 44 Err("io type mismatch\n"); 45 return; 46 } 47 SetIsReady(true); 90 Sobel::Sobel(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name) { 91 pimpl_=new Sobel_impl(this,position,name); 48 92 } 49 93 50 94 Sobel::~Sobel(void) { 95 delete pimpl_; 51 96 } 52 97 53 98 Image* Sobel::Output(void) { 54 return output;99 return pimpl_->output; 55 100 } 56 101 57 void Sobel::UpdateFrom(const io_data *data) {/* 58 Image *cvImage=(Image*)data; 59 IplImage *gimg=cvImage->img; 60 61 data->GetMutex(); 62 output->GetMutex(); 63 dspSobel(gimg,output->img,dx->Value(),dy->Value()); 64 output->ReleaseMutex(); 65 data->ReleaseMutex(); 66 */ 67 output->SetDataTime(data->DataTime()); 68 ProcessUpdate(output); 102 void Sobel::UpdateFrom(const io_data *data) { 103 pimpl_->UpdateFrom(data); 104 ProcessUpdate(pimpl_->output); 69 105 } 70 106 71 107 DataType const &Sobel::GetOutputDataType() const { 72 if( output!=NULL) {73 return output->GetDataType();108 if(pimpl_->output!=NULL) { 109 return pimpl_->output->GetDataType(); 74 110 } else { 75 111 return dummyType;
Note:
See TracChangeset
for help on using the changeset viewer.