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 {
|
---|
22 | namespace core {
|
---|
23 |
|
---|
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;
|
---|
28 |
|
---|
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;
|
---|
38 | case Type::Format::Gray:
|
---|
39 | img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
|
---|
40 | break;
|
---|
41 | default:
|
---|
42 | Err("format no supported");
|
---|
43 | break;
|
---|
44 | }
|
---|
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;
|
---|
57 | case Type::Format::Gray:
|
---|
58 | img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 1);
|
---|
59 | break;
|
---|
60 | default:
|
---|
61 | Err("format no supported");
|
---|
62 | break;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | SetPtrToCircle((void **)&img);
|
---|
67 |
|
---|
68 | if (n > 1)
|
---|
69 | prev = new cvimage(this, width, height, format, name, n - 1);
|
---|
70 | }
|
---|
71 |
|
---|
72 | cvimage::~cvimage() {
|
---|
73 | // printf("destructeur cvimage\n");
|
---|
74 |
|
---|
75 | cvReleaseImage(&img);
|
---|
76 | }
|
---|
77 |
|
---|
78 | void cvimage::CopyDatas(char *dst) const { Warn("non implementé\n"); }
|
---|
79 |
|
---|
80 | } // end namespace core
|
---|
81 | } // end namespace flair
|
---|