source: flair-src/trunk/lib/FlairVisionFilter/src/ImgThreshold.cpp@ 199

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

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

File size: 2.0 KB
Line 
1// created: 2015/10/07
2// filename: ImgThreshold.cpp
3//
4// author: Guillaume Sanahuja
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: ImgThreshold
10//
11//
12/*********************************************************************/
13
14#include "ImgThreshold.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
27ImgThreshold::ImgThreshold(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name),output(0) {
28 GroupBox* reglages_groupbox=new GroupBox(position,name);
29 threshold=new SpinBox(reglages_groupbox->NewRow(),"threshold:",0,255,1,127);
30
31 Printf("todo: pouvoir reutiliser la meme image en sortie\n");
32 try{
33 cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
34 if(imageType.GetFormat()==cvimage::Type::Format::Gray) {
35 output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"threshold");
36 } else {
37 Err("input image is not gray\n");
38 return;
39 }
40 } catch(std::bad_cast& bc) {
41 Err("io type mismatch\n");
42 return;
43 }
44 SetIsReady(true);
45}
46
47ImgThreshold::~ImgThreshold(void) {
48}
49
50cvimage* ImgThreshold::Output(void) {
51 return output;
52}
53
54void ImgThreshold::UpdateFrom(const io_data *data) {
55 cvimage *cvImage=(cvimage*)data;
56 IplImage *gimg=cvImage->img;
57/*
58 data->GetMutex();
59 output->GetMutex();
60 dspThreshold(gimg, output->img, threshold->Value(), 255, CV_THRESH_BINARY);
61 output->ReleaseMutex();
62 data->ReleaseMutex();
63*/
64 output->SetDataTime(data->DataTime());
65 ProcessUpdate(output);
66}
67
68DataType const &ImgThreshold::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.