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

Last change on this file since 252 was 252, checked in by Sanahuja Guillaume, 3 years ago

change io_data CopyDate? to RawRead?

File size: 2.7 KB
RevLine 
[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/*!
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
[15]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
[2]36    */
[15]37    enum class Format {
38      YUYV, /*!< YUYV 16 bits */
39      UYVY, /*!< UYVY 16 bits */
40      BGR,  /*!< BGR 24 bits */
[124]41      Gray, /*!< gray 8 bits */
[15]42    };
43    Type(uint16_t _width, uint16_t _height, Format _format)
44        : width(_width), height(_height), format(_format) {}
[2]45
[15]46    size_t GetSize() const {
47      size_t pixelSize;
48      switch (format) {
[124]49      case Format::Gray:
[15]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"; };
[2]65
[15]66    Format GetFormat() const { return format; };
67    uint16_t GetWidth() const { return width; };
68    uint16_t GetHeight() const { return height; };
[2]69
[15]70  private:
71    uint16_t width;
72    uint16_t height;
73    Format format;
74  };
[2]75
[15]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);
[2]92
[15]93  /*!
94  * \brief Destructor
95  *
96  */
97  ~cvimage();
[2]98
[15]99  /*!
100  * \brief IplImage
101  *
102  * \return IplImage
103  */
104  IplImage *img;
[2]105
[15]106  Type const &GetDataType() const { return dataType; };
[2]107
[15]108private:
109  /*!
[252]110  * \brief Raw read datas
[15]111  *
112  * Reimplemented from io_data. \n
[252]113  * See io_data::RawRead.
[15]114  *
115  * \param dst destination buffer
116  */
[252]117  void RawRead(char *dst) const;
[2]118
[15]119  bool allocate_data;
120  Type dataType;
121};
[2]122
123} // end namespace core
124} // end namespace flair
125
126#endif // CVIMAGE_H
Note: See TracBrowser for help on using the repository browser.