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

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

modifs jpeg

File size: 2.0 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 }
41
42 } catch(std::bad_cast& bc) {
43 Err("io type mismatch\n");
44 }
45}
46
47Sobel::~Sobel(void) {
48}
49
50cvimage* Sobel::Output(void) {
51 return output;
52}
53
54void Sobel::UpdateFrom(const io_data *data) {
55 cvimage *cvImage=(cvimage*)data;
56 IplImage *gimg=cvImage->img;
57/*
58 data->GetMutex();
59 output->GetMutex();
60 dspSobel(gimg,output->img,dx->Value(),dy->Value());
61 output->ReleaseMutex();
62 data->ReleaseMutex();
63*/
64 output->SetDataTime(data->DataTime());
65 ProcessUpdate(output);
66}
67
68DataType const &Sobel::GetOutputDataType() const {
69 if(output!=NULL) {
70 return output->GetDataType();
71 } else {
72 return dummyType;
73 }
74}
75
76} // end namespace filter
77} // end namespace flair
Note: See TracBrowser for help on using the repository browser.