Camera.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
8 
9 // shared
11 
12 namespace dai {
13 namespace node {
14 
18 class Camera : public NodeCRTP<Node, Camera, CameraProperties> {
19  public:
20  constexpr static const char* NAME = "Camera";
21 
22  protected:
24 
25  private:
26  std::shared_ptr<RawCameraControl> rawControl;
27 
28  public:
32  Camera(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId);
33  Camera(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId, std::unique_ptr<Properties> props);
34 
38  static int getScaledSize(int input, int num, int denom);
39 
44 
50  Input inputConfig{*this, "inputConfig", Input::Type::SReceiver, false, 8, {{DatatypeEnum::ImageManipConfig, false}}};
51 
57  Input inputControl{*this, "inputControl", Input::Type::SReceiver, true, 8, {{DatatypeEnum::CameraControl, false}}};
58 
64  Output video{*this, "video", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};
65 
71  Output preview{*this, "preview", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};
72 
78  Output still{*this, "still", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};
79 
85  Output isp{*this, "isp", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};
86 
92  Output raw{*this, "raw", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};
93 
102  Output frameEvent{*this, "frameEvent", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};
103 
104  // /**
105  // * Input for mocking 'isp' functionality.
106  // *
107  // * Default queue is non-blocking with size 8
108  // */
109  // Input mockIsp{*this, "mockIsp", Input::Type::SReceiver, false, 8, {{DatatypeEnum::ImgFrame, false}}};
110 
115  void setBoardSocket(CameraBoardSocket boardSocket);
116 
122 
127  void setCamera(std::string name);
128 
133  std::string getCamera() const;
134 
136  void setImageOrientation(CameraImageOrientation imageOrientation);
137 
140 
141  // TODO(themarpe) - add back
142  // /// Set image type of preview output images.
143  // void setPreviewType(ImgFrame::Type type);
144  // /// Get image type of preview output frames.
145  // ImgFrame::Type getPreviewType() const;
146  // /// Set image type of video output images. Supported AUTO, GRAY, YUV420 and NV12.
147  // void setVideoType(ImgFrame::Type type);
148  // /// Get image type of video output frames. Supported AUTO, GRAY, YUV420 and NV12.
149  // ImgFrame::Type getVideoType() const;
150 
152  void setSize(std::tuple<int, int> size);
154  void setSize(int width, int height);
155 
157  void setPreviewSize(int width, int height);
158 
160  void setPreviewSize(std::tuple<int, int> size);
161 
163  void setVideoSize(int width, int height);
164 
166  void setVideoSize(std::tuple<int, int> size);
167 
169  void setStillSize(int width, int height);
170 
172  void setStillSize(std::tuple<int, int> size);
173 
174  // /**
175  // * Set 'isp' output scaling (numerator/denominator), preserving the aspect ratio.
176  // * The fraction numerator/denominator is simplified first to a irreducible form,
177  // * then a set of hardware scaler constraints applies:
178  // * max numerator = 16, max denominator = 63
179  // */
180  // void setIspScale(int numerator, int denominator);
181 
182  // /// Set 'isp' output scaling, as a tuple <numerator, denominator>
183  // void setIspScale(std::tuple<int, int> scale);
184 
185  // /**
186  // * Set 'isp' output scaling, per each direction. If the horizontal scaling factor
187  // * (horizNum/horizDen) is different than the vertical scaling factor
188  // * (vertNum/vertDen), a distorted (stretched or squished) image is generated
189  // */
190  // void setIspScale(int horizNum, int horizDenom, int vertNum, int vertDenom);
191 
192  // /// Set 'isp' output scaling, per each direction, as <numerator, denominator> tuples
193  // void setIspScale(std::tuple<int, int> horizScale, std::tuple<int, int> vertScale);
194 
199  void setFps(float fps);
200 
208  [[deprecated("setIsp3aFps is unstable")]] void setIsp3aFps(int isp3aFps);
209 
214  float getFps() const;
215 
217  std::tuple<int, int> getPreviewSize() const;
219  int getPreviewWidth() const;
221  int getPreviewHeight() const;
222 
224  std::tuple<int, int> getVideoSize() const;
226  int getVideoWidth() const;
228  int getVideoHeight() const;
229 
231  std::tuple<int, int> getStillSize() const;
233  int getStillWidth() const;
235  int getStillHeight() const;
236 
238  std::tuple<int, int> getSize() const;
240  int getWidth() const;
242  int getHeight() const;
243 
244  // /// Get 'isp' output resolution as size, after scaling
245  // std::tuple<int, int> getIspSize() const;
246  // /// Get 'isp' output width
247  // int getIspWidth() const;
248  // /// Get 'isp' output height
249  // int getIspHeight() const;
250 
251  // /**
252  // * Specify sensor center crop.
253  // * Resolution size / video size
254  // */
255  // void sensorCenterCrop();
256 
257  // /**
258  // * Specifies sensor crop rectangle
259  // * @param x Top left X coordinate
260  // * @param y Top left Y coordinate
261  // */
262  // void setSensorCrop(float x, float y);
263 
264  // /**
265  // * @returns Sensor top left crop coordinates
266  // */
267  // std::tuple<float, float> getSensorCrop() const;
268  // /// Get sensor top left x crop coordinate
269  // float getSensorCropX() const;
270  // /// Get sensor top left y crop coordinate
271  // float getSensorCropY() const;
272 
273  // /**
274  // * Specifies whether preview output should preserve aspect ratio,
275  // * after downscaling from video size or not.
276  // *
277  // * @param keep If true, a larger crop region will be considered to still be able to
278  // * create the final image in the specified aspect ratio. Otherwise video size is resized to fit preview size
279  // */
280  // void setPreviewKeepAspectRatio(bool keep);
281 
282  // /**
283  // * @see setPreviewKeepAspectRatio
284  // * @returns Preview keep aspect ratio option
285  // */
286  // bool getPreviewKeepAspectRatio();
287 
288  // /// Get number of frames in preview pool
289  // int getPreviewNumFramesPool();
290  // /// Get number of frames in video pool
291  // int getVideoNumFramesPool();
292  // /// Get number of frames in still pool
293  // int getStillNumFramesPool();
294  // /// Get number of frames in raw pool
295  // int getRawNumFramesPool();
296  // /// Get number of frames in isp pool
297  // int getIspNumFramesPool();
298 
303 
318  void loadMeshFile(const dai::Path& warpMesh);
319 
324  void loadMeshData(span<const std::uint8_t> warpMesh);
325 
329  void setMeshStep(int width, int height);
331  std::tuple<int, int> getMeshStep() const;
332 
334  void setCalibrationAlpha(float alpha);
337 
347  void setRawOutputPacked(bool packed);
348 };
349 
350 } // namespace node
351 } // namespace dai
dai::node::Camera::Camera
Camera(const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
Definition: Camera.cpp:13
dai::node::Camera::getMeshSource
Properties::WarpMeshSource getMeshSource() const
Gets the source of the warp mesh.
Definition: Camera.cpp:234
dai::node::Camera::setBoardSocket
void setBoardSocket(CameraBoardSocket boardSocket)
Definition: Camera.cpp:35
dai::node::Camera::setVideoSize
void setVideoSize(int width, int height)
Set video output size.
Definition: Camera.cpp:74
dai::node::Camera::setCamera
void setCamera(std::string name)
Definition: Camera.cpp:44
dai::DatatypeEnum::ImageManipConfig
@ ImageManipConfig
dai::node::Camera::getStillSize
std::tuple< int, int > getStillSize() const
Get still size as tuple.
Definition: Camera.cpp:175
dai::node::Camera::raw
Output raw
Definition: Camera.hpp:92
dai::CameraImageOrientation
CameraImageOrientation
Definition: shared/depthai-shared/include/depthai-shared/common/CameraImageOrientation.hpp:11
dai::node::Camera::isp
Output isp
Definition: Camera.hpp:85
fps
static constexpr int fps
Definition: rgb_depth_aligned.cpp:12
ImgFrame.hpp
dai::node::Camera::setImageOrientation
void setImageOrientation(CameraImageOrientation imageOrientation)
Set camera image orientation.
Definition: Camera.cpp:53
dai::CameraBoardSocket
CameraBoardSocket
Definition: shared/depthai-shared/include/depthai-shared/common/CameraBoardSocket.hpp:9
dai::node::Camera::setIsp3aFps
void setIsp3aFps(int isp3aFps)
Definition: Camera.cpp:133
dai::node::Camera::preview
Output preview
Definition: Camera.hpp:71
dai::node::Camera::getScaledSize
static int getScaledSize(int input, int num, int denom)
dai::node::Camera::getPreviewHeight
int getPreviewHeight() const
Get preview height.
Definition: Camera.cpp:156
dai::CameraControl
Definition: CameraControl.hpp:33
dai::node::Camera::loadMeshData
void loadMeshData(span< const std::uint8_t > warpMesh)
Definition: Camera.cpp:238
dai::Node::Output
Definition: Node.hpp:67
dai::NodeCRTP
Definition: Node.hpp:342
dai::node::Camera::getSize
std::tuple< int, int > getSize() const
Get sensor resolution as size.
Definition: Camera.cpp:190
dai::node::Camera::initialControl
CameraControl initialControl
Definition: Camera.hpp:43
dai::node::Camera::getProperties
Properties & getProperties()
Definition: Camera.cpp:29
dai::node::Camera::rawControl
std::shared_ptr< RawCameraControl > rawControl
Definition: Camera.hpp:26
dai::node::Camera::frameEvent
Output frameEvent
Definition: Camera.hpp:102
dai::node::Camera::getBoardSocket
CameraBoardSocket getBoardSocket() const
Definition: Camera.cpp:40
dai::node::Camera::getHeight
int getHeight() const
Get sensor resolution height.
Definition: Camera.cpp:199
dai::node::Camera::getPreviewWidth
int getPreviewWidth() const
Get preview width.
Definition: Camera.cpp:152
dai::node::Camera::getPreviewSize
std::tuple< int, int > getPreviewSize() const
Get preview size as tuple.
Definition: Camera.cpp:148
DAI_SPAN_NAMESPACE_NAME::detail::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: span.hpp:167
dai::node::Camera::getStillHeight
int getStillHeight() const
Get still height.
Definition: Camera.cpp:185
dai::node::Camera::NAME
constexpr static const char * NAME
Definition: Camera.hpp:20
dai::node::Camera::setRawOutputPacked
void setRawOutputPacked(bool packed)
Definition: Camera.cpp:278
dai::node::Camera::getWidth
int getWidth() const
Get sensor resolution width.
Definition: Camera.cpp:195
dai::node::Camera::getCamera
std::string getCamera() const
Definition: Camera.cpp:48
dai::Properties
Base Properties structure.
Definition: Properties.hpp:8
dai::node::Camera::setFps
void setFps(float fps)
Definition: Camera.cpp:129
CameraControl.hpp
dai::node::Camera::getCalibrationAlpha
tl::optional< float > getCalibrationAlpha() const
Get calibration alpha parameter that determines FOV of undistorted frames.
Definition: Camera.cpp:274
dai::node::Camera::loadMeshFile
void loadMeshFile(const dai::Path &warpMesh)
Definition: Camera.cpp:252
dai::node::Camera::getMeshStep
std::tuple< int, int > getMeshStep() const
Gets the distance between mesh points.
Definition: Camera.cpp:266
dai::node::Camera::setMeshSource
void setMeshSource(Properties::WarpMeshSource source)
Set the source of the warp mesh or disable.
Definition: Camera.cpp:231
dai::DatatypeEnum::CameraControl
@ CameraControl
tl::optional< float >
dai::node::Camera::setCalibrationAlpha
void setCalibrationAlpha(float alpha)
Set calibration alpha parameter that determines FOV of undistorted frames.
Definition: Camera.cpp:270
dai::node::Camera::setMeshStep
void setMeshStep(int width, int height)
Definition: Camera.cpp:262
dai::node::Camera::setSize
void setSize(std::tuple< int, int > size)
Set desired resolution. Sets sensor size to best fit.
Definition: Camera.cpp:89
dai::node::Camera::getVideoWidth
int getVideoWidth() const
Get video width.
Definition: Camera.cpp:166
dai::CameraProperties::WarpMeshSource
WarpMeshSource
Definition: CameraProperties.hpp:152
dai::node::Camera::setPreviewSize
void setPreviewSize(int width, int height)
Set preview output size.
Definition: Camera.cpp:64
dai::node::Camera::getStillWidth
int getStillWidth() const
Get still width.
Definition: Camera.cpp:181
dai::node::Camera::video
Output video
Definition: Camera.hpp:64
dai::Path
Represents paths on a filesystem; accepts utf-8, Windows utf-16 wchar_t, or std::filesystem::path.
Definition: Path.hpp:27
dai::node::Camera::getImageOrientation
CameraImageOrientation getImageOrientation() const
Get camera image orientation.
Definition: Camera.cpp:58
dai::node::Camera::still
Output still
Definition: Camera.hpp:78
dai::DatatypeEnum::ImgFrame
@ ImgFrame
dai::node::Camera::getVideoSize
std::tuple< int, int > getVideoSize() const
Get video size as tuple.
Definition: Camera.cpp:161
span.hpp
dai
Definition: CameraExposureOffset.hpp:6
Node.hpp
dai::node::Camera::getFps
float getFps() const
Definition: Camera.cpp:137
CameraProperties.hpp
dai::node::Camera::inputConfig
Input inputConfig
Definition: Camera.hpp:50
dai::node::Camera
Camera node. Experimental node, for both mono and color types of sensors.
Definition: Camera.hpp:18
dai::node::Camera::setStillSize
void setStillSize(int width, int height)
Set still output size.
Definition: Camera.cpp:94
dai::node::Camera::getVideoHeight
int getVideoHeight() const
Get video height.
Definition: Camera.cpp:170
dai::node::Camera::inputControl
Input inputControl
Definition: Camera.hpp:57


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