[2] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 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 |
|
---|
[15] | 21 | namespace flair {
|
---|
| 22 | namespace core {
|
---|
[2] | 23 |
|
---|
[15] | 24 | cvimage::cvimage(const Object *parent, uint16_t width, uint16_t height,
|
---|
| 25 | Type::Format format, string name, bool allocate_data, int n)
|
---|
| 26 | : io_data(parent, name, n), dataType(width, height, format) {
|
---|
| 27 | this->allocate_data = allocate_data;
|
---|
[2] | 28 |
|
---|
[15] | 29 | if (allocate_data) {
|
---|
| 30 | switch (format) {
|
---|
| 31 | case Type::Format::YUYV:
|
---|
| 32 | case Type::Format::UYVY:
|
---|
| 33 | img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 2);
|
---|
| 34 | break;
|
---|
| 35 | case Type::Format::BGR:
|
---|
| 36 | img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
|
---|
| 37 | break;
|
---|
[124] | 38 | case Type::Format::Gray:
|
---|
[15] | 39 | img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
|
---|
| 40 | break;
|
---|
| 41 | default:
|
---|
| 42 | Err("format no supported");
|
---|
| 43 | break;
|
---|
[2] | 44 | }
|
---|
[15] | 45 | } else {
|
---|
| 46 | if (n > 1)
|
---|
| 47 | Err("number of samples!=1 not possible when not allocating data\n");
|
---|
| 48 | n = 1;
|
---|
| 49 | switch (format) {
|
---|
| 50 | case Type::Format::YUYV:
|
---|
| 51 | case Type::Format::UYVY:
|
---|
| 52 | img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 2);
|
---|
| 53 | break;
|
---|
| 54 | case Type::Format::BGR:
|
---|
| 55 | img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3);
|
---|
| 56 | break;
|
---|
[124] | 57 | case Type::Format::Gray:
|
---|
[15] | 58 | img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 1);
|
---|
| 59 | break;
|
---|
| 60 | default:
|
---|
| 61 | Err("format no supported");
|
---|
| 62 | break;
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
[2] | 65 |
|
---|
[15] | 66 | SetPtrToCircle((void **)&img);
|
---|
[2] | 67 |
|
---|
[15] | 68 | if (n > 1)
|
---|
| 69 | prev = new cvimage(this, width, height, format, name, n - 1);
|
---|
[2] | 70 | }
|
---|
| 71 |
|
---|
| 72 | cvimage::~cvimage() {
|
---|
[15] | 73 | // printf("destructeur cvimage\n");
|
---|
[2] | 74 |
|
---|
[15] | 75 | cvReleaseImage(&img);
|
---|
[2] | 76 | }
|
---|
| 77 |
|
---|
[252] | 78 | void cvimage::RawRead(char *dst) const { Warn("non implementé\n"); }
|
---|
[2] | 79 |
|
---|
| 80 | } // end namespace core
|
---|
| 81 | } // end namespace flair
|
---|