roviz  0.7
Code Documentation of roviz
image.h
1 #ifndef IMAGE_H
2 #define IMAGE_H
3 
4 #include <initializer_list>
5 #include "core/export_handling.h"
6 #include "streams/stream_object.h"
7 
8 #ifdef QT_PRESENT
9  #include <QImage>
10 #endif
11 #ifdef OPENCV_PRESENT
12  #include <opencv2/core.hpp>
13  #include <opencv2/imgproc.hpp>
14 #endif
15 
16 class ImagePrivate;
17 class OutputPrivate;
18 class StreamWidget;
19 
35 class ROVIZ_EXPORT Image : public StreamObject
36 {
37 public:
38 
42  enum Format
43  {
44  NoFormat,
45  RGB555,
46  RGB888,
47  Gray8,
48  YUV422,
49  YUV422_Flipped, // Rotated by 180 degrees (you probably won't use that)
50  BGR_CV
51  };
52 
61  Image(const StreamObject &base);
62 
69  Image(std::initializer_list<SourceID> sources = {});
70 
71 #ifdef QT_PRESENT
72 
81  Image(QImage img, std::initializer_list<SourceID> sources = {});
82 #endif
83 #ifdef OPENCV_PRESENT
84 
93  Image(cv::Mat img, std::initializer_list<SourceID> sources = {});
94 #endif
95 
96  ~Image() = default;
97 
101  int width(void) const;
102 
106  int height(void) const;
107 
111  enum Format format(void) const;
112 
116  int bitsPerPixel(void) const;
117 
121  int bytesPerPixel(void) const;
122 
126  int dataLength(void) const;
127 
131  const unsigned char *data(void) const;
132 
133 #ifdef QT_PRESENT
134 
143  const QImage toQt(void);
144 #endif
145 #ifdef OPENCV_PRESENT
146 
157  const cv::_InputArray toCv(void);
158 #endif
159 
160 protected:
161  ImagePrivate *_this;
162 
163  // Used by ImageMutable
164  Image(bool do_init, std::initializer_list<SourceID> sources);
165 
166 // Handle the displaying of the image
167 #if ROVIZ_BACKEND == ROVIZ_BACKEND_Dev
168 public:
176  static StreamWidget *initWidget(OutputPrivate *out);
177 #endif
178 };
179 
180 DECLARE_STREAM_OBJECT(Image)
181 
182 #endif // IMAGE_H
Base class of all objects that can be transported with a stream.
Definition: stream_object.h:39
Base class for all widgets representing a StreamObject.
Definition: stream_widget.h:14
Private part of the Ouput class.
Definition: output_p.h:16
Format
Enum of all supported image formats.
Definition: image.h:42
A portable image class with smart memory management.
Definition: image.h:35
Private part of the Image class.
Definition: image_p.h:19