Flair
Framework Libre Air
cvimage.h
Go to the documentation of this file.
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}
13 #ifndef CVIMAGE_H
14 #define CVIMAGE_H
15 
16 #include <cxcore.h>
17 #include <io_data.h>
18 #include <stdint.h>
19 
20 namespace flair {
21 namespace core {
29 class cvimage : public io_data {
30 public:
31  class Type : public DataType {
32  public:
37  enum class Format {
38  YUYV,
39  UYVY,
40  BGR,
41  Gray,
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 
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 
97  ~cvimage();
98 
104  IplImage *img;
105 
106  Type const &GetDataType() const { return dataType; };
107 
108 private:
117  void RawRead(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
Abstract class for data types.
Definition: io_data.h:94
Definition: io_data.h:26
namespace of the flair Framework
Definition: Ahrs.h:19
Abstract class for data types.
Definition: cvimage.h:31
Format
Definition: cvimage.h:37
cvimage(const Object *parent, uint16_t width, uint16_t height, Type::Format format, std::string name="", bool allocate_data=true, int n=1)
Constructor.
~cvimage()
Destructor.
Class defining an image of kind IplImage.
Definition: cvimage.h:29
IplImage * img
IplImage.
Definition: cvimage.h:104
Object(const Object *parent=NULL, std::string name="", std::string type="")
Constructor.