ImgFrame.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <chrono>
4 #include <unordered_map>
5 #include <vector>
6 
7 // project
8 #include "depthai/build/config.hpp"
11 
12 // shared
14 
15 // optional
16 #ifdef DEPTHAI_HAVE_OPENCV_SUPPORT
17  #include <opencv2/opencv.hpp>
18 #endif
19 
20 namespace dai {
21 
25 class ImgFrame : public Buffer {
26  std::shared_ptr<RawBuffer> serialize() const override;
28 
29  public:
30  // Raw* mirror
36 
41  ImgFrame();
42  explicit ImgFrame(std::shared_ptr<RawImgFrame> ptr);
43  virtual ~ImgFrame() = default;
44 
45  // getters
49  std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestamp(CameraExposureOffset offset) const;
50 
55  std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestampDevice(CameraExposureOffset offset) const;
56 
60  unsigned int getInstanceNum() const;
61 
65  unsigned int getCategory() const;
66 
70  unsigned int getWidth() const;
71 
75  unsigned int getHeight() const;
76 
80  Type getType() const;
81 
85  std::chrono::microseconds getExposureTime() const;
86 
90  int getSensitivity() const;
91 
95  int getColorTemperature() const;
96 
100  int getLensPosition() const;
101 
105  float getLensPositionRaw() const;
106 
107  // setters
111  ImgFrame& setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
112 
116  ImgFrame& setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
117 
123  ImgFrame& setInstanceNum(unsigned int instance);
124 
128  ImgFrame& setCategory(unsigned int category);
129 
135  ImgFrame& setSequenceNum(int64_t seq);
136 
142  ImgFrame& setWidth(unsigned int width);
143 
149  ImgFrame& setHeight(unsigned int height);
150 
157  ImgFrame& setSize(unsigned int width, unsigned int height);
158 
164  ImgFrame& setSize(std::tuple<unsigned int, unsigned int> size);
165 
172 
173 // Optional - OpenCV support
174 #ifdef DEPTHAI_HAVE_OPENCV_SUPPORT
175 
182  ImgFrame& setFrame(cv::Mat frame);
183 
192  cv::Mat getFrame(bool copy = false);
193 
204  cv::Mat getCvFrame();
205 
206 #else
207 
208  template <typename... T>
210  static constexpr bool value = false;
211  };
212  template <typename... T>
214  static_assert(dependent_false<T...>::value, "Library not configured with OpenCV support");
215  return *this;
216  }
217  template <typename... T>
218  void getFrame(T...) {
219  static_assert(dependent_false<T...>::value, "Library not configured with OpenCV support");
220  }
221  template <typename... T>
222  void getCvFrame(T...) {
223  static_assert(dependent_false<T...>::value, "Library not configured with OpenCV support");
224  }
225 
226 #endif
227 };
228 
229 } // namespace dai
dai::RawImgFrame::Specs
Definition: RawImgFrame.hpp:154
dai::ImgFrame::getFrame
void getFrame(T...)
Definition: ImgFrame.hpp:218
dai::ImgFrame::setTimestampDevice
ImgFrame & setTimestampDevice(std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)
Definition: pipeline/datatype/ImgFrame.cpp:84
dai::RawImgFrame
RawImgFrame structure.
Definition: RawImgFrame.hpp:12
dai::ImgFrame::getLensPositionRaw
float getLensPositionRaw() const
Definition: pipeline/datatype/ImgFrame.cpp:75
dai::ImgFrame::setSequenceNum
ImgFrame & setSequenceNum(int64_t seq)
Definition: pipeline/datatype/ImgFrame.cpp:96
dai::RawImgFrame::CameraSettings
Definition: RawImgFrame.hpp:166
dai::RawImgFrame::Type
Type
Definition: RawImgFrame.hpp:13
dai::ImgFrame::setSize
ImgFrame & setSize(unsigned int width, unsigned int height)
Definition: pipeline/datatype/ImgFrame.cpp:109
dai::ImgFrame::setWidth
ImgFrame & setWidth(unsigned int width)
Definition: pipeline/datatype/ImgFrame.cpp:99
dai::Buffer::getTimestamp
std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > getTimestamp() const
Definition: Buffer.cpp:26
dai::ImgFrame::dependent_false::value
static constexpr bool value
Definition: ImgFrame.hpp:210
dai::ImgFrame::getType
Type getType() const
Definition: pipeline/datatype/ImgFrame.cpp:59
dai::Buffer::getTimestampDevice
std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > getTimestampDevice() const
Definition: Buffer.cpp:30
dai::ImgFrame::dependent_false
Definition: ImgFrame.hpp:209
dai::ImgFrame::getHeight
unsigned int getHeight() const
Definition: pipeline/datatype/ImgFrame.cpp:56
dai::ImgFrame::~ImgFrame
virtual ~ImgFrame()=default
RawImgFrame.hpp
dai::ImgFrame::getCategory
unsigned int getCategory() const
Definition: pipeline/datatype/ImgFrame.cpp:50
dai::ImgFrame::getExposureTime
std::chrono::microseconds getExposureTime() const
Definition: pipeline/datatype/ImgFrame.cpp:62
DAI_SPAN_NAMESPACE_NAME::detail::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: span.hpp:167
dai::ImgFrame::getColorTemperature
int getColorTemperature() const
Definition: pipeline/datatype/ImgFrame.cpp:68
dai::ImgFrame::getInstanceNum
unsigned int getInstanceNum() const
Definition: pipeline/datatype/ImgFrame.cpp:47
dai::CameraExposureOffset
CameraExposureOffset
Definition: CameraExposureOffset.hpp:11
dai::ImgFrame::getCvFrame
void getCvFrame(T...)
Definition: ImgFrame.hpp:222
dai::ImgFrame::ImgFrame
ImgFrame()
Definition: pipeline/datatype/ImgFrame.cpp:11
dai::ImgFrame
Definition: ImgFrame.hpp:25
nanorpc::core::detail::pack::meta::type
type
Definition: pack_meta.h:26
dai::ImgFrame::setCategory
ImgFrame & setCategory(unsigned int category)
Definition: pipeline/datatype/ImgFrame.cpp:92
dai::ImgFrame::setInstanceNum
ImgFrame & setInstanceNum(unsigned int instance)
Definition: pipeline/datatype/ImgFrame.cpp:88
dai::ImgFrame::serialize
std::shared_ptr< RawBuffer > serialize() const override
Definition: pipeline/datatype/ImgFrame.cpp:7
dai::Buffer
Base message - buffer of binary data.
Definition: Buffer.hpp:13
dai::ImgFrame::setTimestamp
ImgFrame & setTimestamp(std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > timestamp)
Definition: pipeline/datatype/ImgFrame.cpp:80
dai::ImgFrame::setType
ImgFrame & setType(Type type)
Definition: pipeline/datatype/ImgFrame.cpp:118
dai::ImgFrame::setHeight
ImgFrame & setHeight(unsigned int height)
Definition: pipeline/datatype/ImgFrame.cpp:105
dai::ImgFrame::getLensPosition
int getLensPosition() const
Definition: pipeline/datatype/ImgFrame.cpp:71
dai::ImgFrame::setFrame
ImgFrame & setFrame(T...)
Definition: ImgFrame.hpp:213
dai::ImgFrame::img
RawImgFrame & img
Definition: ImgFrame.hpp:27
Buffer.hpp
dai
Definition: CameraExposureOffset.hpp:6
CameraExposureOffset.hpp
dai::ImgFrame::getSensitivity
int getSensitivity() const
Definition: pipeline/datatype/ImgFrame.cpp:65
dai::ImgFrame::getWidth
unsigned int getWidth() const
Definition: pipeline/datatype/ImgFrame.cpp:53


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19