source: flair-src/trunk/lib/FlairVisionFilter/src/CvtColor.cpp@ 124

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

modifs jpeg

File size: 2.2 KB
Line 
1// created: 2014/07/17
2// filename: CvtColor.cpp
3//
4// author: Guillaume Sanahuja
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: Image color conversion
10//
11//
12/*********************************************************************/
13
14#include "CvtColor.h"
15#include <cvimage.h>
16#include <typeinfo>
17
18using std::string;
19using namespace flair::core;
20
21namespace flair { namespace filter {
22
23CvtColor::CvtColor(const core::IODevice* parent,std::string name,Conversion_t conversion) : IODevice(parent,name),output(0) {
24 this->conversion=conversion;
25
26 switch(conversion) {
27 case Conversion_t::ToGray:
28 try{
29 cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
30 output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),cvimage::Type::Format::Gray,"conversion",true,2);
31
32 } catch(std::bad_cast& bc) {
33 Err("io type mismatch\n");
34 }
35 break;
36 default:
37 Err("conversion not supported\n");
38 }
39}
40
41CvtColor::~CvtColor(void) {}
42
43cvimage* CvtColor::Output(void) {
44 return output;
45
46}
47
48DataType const &CvtColor::GetOutputDataType() const {
49 if(output!=NULL) {
50 return output->GetDataType();
51 } else {
52 return dummyType;
53 }
54}
55
56void CvtColor::UpdateFrom(const io_data *data) {
57 IplImage *img=((cvimage*)data)->img;
58
59 data->GetMutex();
60 output->GetMutex();
61
62 switch(conversion) {
63 case Conversion_t::ToGray:
64 switch(((cvimage*)data)->GetDataType().GetFormat()) {
65 case cvimage::Type::Format::YUYV:
66 //dspCvtColor(img,output->img,DSP_YUYV2GRAY);
67 break;
68 case cvimage::Type::Format::UYVY:
69 //dspCvtColor(img,output->img,DSP_UYVY2GRAY);
70 break;
71 case cvimage::Type::Format::BGR:
72 //dspCvtColor(img,output->img,DSP_BGR2GRAY);
73 break;
74 default:
75 Err("input format not supported\n");
76 }
77 break;
78 default:
79 Err("conversion not supported\n");
80 }
81
82 output->ReleaseMutex();
83 data->ReleaseMutex();
84
85 output->SetDataTime(data->DataTime());
86 ProcessUpdate(output);
87}
88
89} // end namespace filter
90} // end namespace flair
Note: See TracBrowser for help on using the repository browser.