Changeset 15 in flair-src for trunk/lib/FlairCore/src/cvimage.h


Ignore:
Timestamp:
04/08/16 15:40:57 (7 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/cvimage.h

    r2 r15  
    1818#include <stdint.h>
    1919
    20 namespace flair
    21 {
    22 namespace 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     *
     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
    3036    */
    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) {}
     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) {}
    4645
    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";};
     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"; };
    6665
    67             Format GetFormat() const {return format;};
    68             uint16_t GetWidth() const {return width;};
    69             uint16_t GetHeight() const {return height;};
     66    Format GetFormat() const { return format; };
     67    uint16_t GetWidth() const { return width; };
     68    uint16_t GetHeight() const { return height; };
    7069
    71         private:
    72             uint16_t width;
    73             uint16_t height;
    74             Format format;
     70  private:
     71    uint16_t width;
     72    uint16_t height;
     73    Format format;
     74  };
    7575
    76         };
     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);
    7792
    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);
     93  /*!
     94  * \brief Destructor
     95  *
     96  */
     97  ~cvimage();
    9198
    92         /*!
    93         * \brief Destructor
    94         *
    95         */
    96         ~cvimage();
     99  /*!
     100  * \brief IplImage
     101  *
     102  * \return IplImage
     103  */
     104  IplImage *img;
    97105
    98         /*!
    99         * \brief IplImage
    100         *
    101         * \return IplImage
    102         */
    103         IplImage* img;
     106  Type const &GetDataType() const { return dataType; };
    104107
    105         Type const&GetDataType() const {return dataType;};
     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;
    106118
    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     };
     119  bool allocate_data;
     120  Type dataType;
     121};
    121122
    122123} // end namespace core
Note: See TracChangeset for help on using the changeset viewer.