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

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

modifs uav vrpn i686

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