source: flair-src/trunk/lib/FlairCore/src/cvimage.h@ 117

Last change on this file since 117 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

File size: 2.7 KB
Line 
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/*!
6 * \file cvimage.h
7 * \brief Class defining an image of kind IplImage
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2012/03/20
10 * \version 4.0
11 */
12
13#ifndef CVIMAGE_H
14#define CVIMAGE_H
15
16#include <cxcore.h>
17#include <io_data.h>
18#include <stdint.h>
19
20namespace flair {
21namespace core {
22/*! \class cvimage
23*
24* \brief Class defining an image of kind IplImage
25*
26* IplImage is an image struct defined in OpenCV.
27*
28*/
29class cvimage : public io_data {
30public:
31 class Type : public DataType {
32 public:
33 /*!
34 \enum Format_t
35 \brief Picture formats
36 */
37 enum class Format {
38 YUYV, /*!< YUYV 16 bits */
39 UYVY, /*!< UYVY 16 bits */
40 BGR, /*!< BGR 24 bits */
41 GRAY, /*!< gray 8 bits */
42 };
43 Type(uint16_t _width, uint16_t _height, Format _format)
44 : width(_width), height(_height), format(_format) {}
45
46 size_t GetSize() const {
47 size_t pixelSize;
48 switch (format) {
49 case Format::GRAY:
50 pixelSize = 1;
51 break;
52 case Format::YUYV:
53 case Format::UYVY:
54 pixelSize = 2;
55 break;
56 case Format::BGR:
57 pixelSize = 3;
58 break;
59 default:
60 pixelSize = 0; // TODO should throw an exception instead
61 }
62 return pixelSize * width * height;
63 }
64 std::string GetDescription() const { return "cv image"; };
65
66 Format GetFormat() const { return format; };
67 uint16_t GetWidth() const { return width; };
68 uint16_t GetHeight() const { return height; };
69
70 private:
71 uint16_t width;
72 uint16_t height;
73 Format format;
74 };
75
76 /*!
77 * \brief Constructor
78 *
79 * Construct an io_data representing an IplImage.
80 *
81 * \param parent parent
82 * \param width image width
83 * \param height image height
84 * \param name name
85 * \param allocate_data if true, IplImage image data is allocated; otherwise
86 *img->imagedata must be changed
87 * \param n number of samples
88 */
89 cvimage(const Object *parent, uint16_t width, uint16_t height,
90 Type::Format format, std::string name = "", bool allocate_data = true,
91 int n = 1);
92
93 /*!
94 * \brief Destructor
95 *
96 */
97 ~cvimage();
98
99 /*!
100 * \brief IplImage
101 *
102 * \return IplImage
103 */
104 IplImage *img;
105
106 Type const &GetDataType() const { return dataType; };
107
108private:
109 /*!
110 * \brief Copy datas
111 *
112 * Reimplemented from io_data. \n
113 * See io_data::CopyDatas.
114 *
115 * \param dst destination buffer
116 */
117 void CopyDatas(char *dst) const;
118
119 bool allocate_data;
120 Type dataType;
121};
122
123} // end namespace core
124} // end namespace flair
125
126#endif // CVIMAGE_H
Note: See TracBrowser for help on using the repository browser.