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

Last change on this file since 247 was 157, checked in by Sanahuja Guillaume, 7 years ago

iadded isready to iodevice:
avoid problem of imu not ready in ardrone2

File size: 2.1 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 <cvimage.h>
16#include <Layout.h>
17#include <GroupBox.h>
18#include <SpinBox.h>
19#include <typeinfo>
20
21using std::string;
22using namespace flair::core;
23using namespace flair::gui;
24
25namespace flair { namespace filter {
26
27Sobel::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 //cvimage devrait accepter un type dans son constructeur pour construire un type identique
34 try{
35 cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
36 if(imageType.GetFormat()==cvimage::Type::Format::Gray) {
37 output=new cvimage(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);
48}
49
50Sobel::~Sobel(void) {
51}
52
53cvimage* Sobel::Output(void) {
54 return output;
55}
56
57void Sobel::UpdateFrom(const io_data *data) {
58 cvimage *cvImage=(cvimage*)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);
69}
70
71DataType const &Sobel::GetOutputDataType() const {
72 if(output!=NULL) {
73 return output->GetDataType();
74 } else {
75 return dummyType;
76 }
77}
78
79} // end namespace filter
80} // end namespace flair
Note: See TracBrowser for help on using the repository browser.