source: flair-dev/trunk/include/FlairCore/cvimage.h@ 2

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 8 years ago

initial commit flaircore

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