[2] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %flair:license}
|
---|
| 5 | // created: 2012/03/20
|
---|
| 6 | // filename: cvimage.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Class defining an image of kind IplImage
|
---|
| 14 | //
|
---|
| 15 | /*********************************************************************/
|
---|
| 16 |
|
---|
| 17 | #include "cvimage.h"
|
---|
| 18 |
|
---|
| 19 | using std::string;
|
---|
| 20 |
|
---|
| 21 | namespace flair { namespace core {
|
---|
| 22 |
|
---|
| 23 | cvimage::cvimage(const Object* parent,uint16_t width,uint16_t height,Type::Format format,string name,bool allocate_data,int n): io_data(parent,name,n),dataType(width,height,format) {
|
---|
| 24 | this->allocate_data=allocate_data;
|
---|
| 25 |
|
---|
| 26 | if(allocate_data) {
|
---|
| 27 | switch(format) {
|
---|
| 28 | case Type::Format::YUYV:
|
---|
| 29 | case Type::Format::UYVY:
|
---|
| 30 | img=cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,2);
|
---|
| 31 | break;
|
---|
| 32 | case Type::Format::BGR:
|
---|
| 33 | img=cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3);
|
---|
| 34 | break;
|
---|
| 35 | case Type::Format::GRAY:
|
---|
| 36 | img=cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,1);
|
---|
| 37 | break;
|
---|
| 38 | default:
|
---|
| 39 | Err("format no supported");
|
---|
| 40 | break;
|
---|
| 41 | }
|
---|
| 42 | } else {
|
---|
| 43 | if(n>1) Err("number of samples!=1 not possible when not allocating data\n");
|
---|
| 44 | n=1;
|
---|
| 45 | switch(format) {
|
---|
| 46 | case Type::Format::YUYV:
|
---|
| 47 | case Type::Format::UYVY:
|
---|
| 48 | img=cvCreateImageHeader(cvSize(width,height),IPL_DEPTH_8U,2);
|
---|
| 49 | break;
|
---|
| 50 | case Type::Format::BGR:
|
---|
| 51 | img=cvCreateImageHeader(cvSize(width,height),IPL_DEPTH_8U,3);
|
---|
| 52 | break;
|
---|
| 53 | case Type::Format::GRAY:
|
---|
| 54 | img=cvCreateImageHeader(cvSize(width,height),IPL_DEPTH_8U,1);
|
---|
| 55 | break;
|
---|
| 56 | default:
|
---|
| 57 | Err("format no supported");
|
---|
| 58 | break;
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | SetPtrToCircle((void**)&img);
|
---|
| 63 |
|
---|
| 64 | if(n>1) prev=new cvimage(this,width,height,format,name,n-1);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | cvimage::~cvimage() {
|
---|
| 68 | //printf("destructeur cvimage\n");
|
---|
| 69 |
|
---|
| 70 | cvReleaseImage(&img);
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | void cvimage::CopyDatas(char* dst) const {
|
---|
| 74 | Warn("non implementé\n");
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | } // end namespace core
|
---|
| 78 | } // end namespace flair
|
---|