摄像头
Camera 是一个统一的单一源节点,取代了独立的 ColorCamera 和 MonoCamera 节点。 它生成 ImgFrame 消息,可用于图像处理和神经网络推理。关键特性
- 当你未指定传感器分辨率和FPS时,自动选择 — 无需手动记录。
requestOutput()
Py
1cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
2 resize_mode=dai.ImgResizeMode.CROP,
3 enableUndistortion=True)- 通过
enableUndistortion(默认 =None)为每个输出选择是否启用去畸变。 它不会自动应用于任何流。 - 去畸变保留原始帧内参,这意味着有效视场角(FOV)通常在角落处略有减小,尤其是广角镜头。
requestFullResolutionOutput()带有安全保护(除非传递useHighestResolution=True,否则保持在 ≤ 5 K×4 K 以内)。setMockIsp()用于合成或录制的输入(附加ReplayVideo节点以提供预捕获帧)。
ColorCamera 或 MonoCamera 升级?只需查找替换节点创建代码,并删除任何手动的 setIspScale() 逻辑。放置节点
Python
Python
1with dai.Pipeline() as pipeline:
2 cam = pipeline.create(dai.node.Camera)
3 cam.build(dai.CameraBoardSocket.CAM_A) # 可选——否则自动检测输入与输出
缩放模式

- 裁剪(Crop):NN精度无下降。缺点:画面被裁剪,无法获得完整视场角。
- 信箱模式(Letterbox):保留完整视场角。缺点:较小的“画面”可能导致特征减少,降低NN精度。
- 拉伸(Stretch):保留完整视场角。缺点:由于画面被拉伸,NN精度可能下降。
Python
1cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
2 resize_mode=dai.ImgResizeMode.CROP)
3cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
4 resize_mode=dai.ImgResizeMode.RESIZE)
5cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
6 resize_mode=dai.ImgResizeMode.LETTERBOX)使用示例
Python
Python
1pipeline = dai.Pipeline()
2
3cam = pipeline.create(dai.node.Camera)
4cam.build(boardSocket=dai.CameraBoardSocket.CAM_A)
5
6# 1) 用于视频编码器的低延迟预览
7nn_in = cam.requestOutput(size=(300,300), type=dai.ImgFrame.Type.NV12, fps=30)
8
9# 2) 用于录制的HD流
10hd_out = cam.requestOutput(size=(1280,720), type=dai.ImgFrame.Type.BGR888p, fps=30)
11
12# 3) 每秒一张全分辨率静态图
13full = cam.requestFullResolutionOutput(type=dai.ImgFrame.Type.BGR888p, fps=1)
14
15# 链接到下游节点……平台特定限制
RVC2
ISP 持续处理能力约 600 MP/s(约 4K @ 30 fps)——在运行重型NN和视频编码器时需据此预算。 3A 运行在嵌入式微DSP上,所有摄像头流合计最高约 250 fps。
更多示例
API 参考
class
dai::node::Camera
variable
CameraControl initialControl
Initial control options to apply to sensor
variable
Input inputControl
variable
Input mockIsp
Input for mocking 'isp' functionality on RVC2. Default queue is blocking with size 8
variable
Output raw
Outputs ImgFrame message that carries RAW10-packed (MIPI CSI-2 format) frame data.Captured directly from the camera sensor, and the source for the 'isp' output.
variable
OutputMap dynamicOutputs
function
Node::Output * requestOutput(const std::pair< uint32_t, uint32_t > & size, std::optional< ImgFrame::Type > type, ImgResizeMode resizeMode, std::optional< float > fps, std::optional< bool > enableUndistortion)Get video output with specified size.
function
Node::Output * requestOutput(const Capability & capability, bool onHost)Request output with advanced controls. Mainly to be used by custom node writers.
function
Node::Output * requestFullResolutionOutput(std::optional< ImgFrame::Type > type, std::optional< float > fps, bool useHighestResolution)Get a high resolution output with full FOV on the sensor. By default the function will not use the resolutions higher than 5000x4000, as those often need a lot of resources, making them hard to use in combination with other nodes.
Parameters
- type: Type of the output (NV12, BGR, ...) - by default it's auto-selected for best performance
- fps: FPS of the output - by default it's auto-selected to highest possible that a sensor config support or 30, whichever is lower
- useHighestResolution: If true, the function will use the highest resolution available on the sensor, even if it's higher than 5000x4000
function
Node::Output * requestIspOutput(std::optional< float > fps)Request output with isp resolution. The fps does not vote.
function
std::shared_ptr< Camera > build(dai::CameraBoardSocket boardSocket, const std::optional< std::pair< uint32_t, uint32_t >> & sensorResolution, std::optional< float > sensorFps)Build with a specific board socket
Parameters
- boardSocket: Board socket to use
- sensorResolution: Sensor resolution to use - by default it's auto-detected from the requested outputs
- sensorFps: Sensor FPS to use - by default it's auto-detected from the requested outputs (maximum is used)
inline function
std::shared_ptr< Camera > setSensorType(CameraSensorType sensorType)Set the sensor type to use
Parameters
- sensorType: Sensor type to use
inline function
CameraSensorType getSensorType()Get the sensor type
Returns
Sensor type
function
std::shared_ptr< Camera > setImageOrientation(CameraImageOrientation imageOrientation)Set camera image orientation
Parameters
- imageOrientation: Image orientation to set
Returns
Shared pointer to the camera node
function
CameraImageOrientation getImageOrientation()Get camera image orientation
Returns
Image orientation
function
std::shared_ptr< Camera > build(dai::CameraBoardSocket boardSocket, ReplayVideo & replay)Build with a specific board socket and mock input
function
std::shared_ptr< Camera > build(ReplayVideo & replay)Build with mock input
function
uint32_t getMaxWidth()Get max width of the camera (can only be called after build)
function
uint32_t getMaxHeight()Get max height of the camera (can only be called after build)
function
CameraBoardSocket getBoardSocket()Retrieves which board socket to use
Returns
Board socket to use
function
std::shared_ptr< Camera > setRawNumFramesPool(int num)Set number of frames in raw pool (will be automatically reduced if the maximum pool memory size is exceeded)
Parameters
- num: Number of frames
Returns
Shared pointer to the camera node
function
std::shared_ptr< Camera > setMaxSizePoolRaw(int size)Set maximum size of raw pool
Parameters
- size: Maximum size in bytes of raw pool
Returns
Shared pointer to the camera node
function
std::shared_ptr< Camera > setIspNumFramesPool(int num)Set number of frames in isp pool (will be automatically reduced if the maximum pool memory size is exceeded)
Parameters
- num: Number of frames
Returns
Shared pointer to the camera node
function
std::shared_ptr< Camera > setMaxSizePoolIsp(int size)Set maximum size of isp pool
Parameters
- size: Maximum size in bytes of isp pool
Returns
Shared pointer to the camera node
function
std::shared_ptr< Camera > setNumFramesPools(int raw, int isp, int outputs)Set number of frames in all pools (will be automatically reduced if the maximum pool memory size is exceeded)
Parameters
- raw: Number of frames in raw pool
- isp: Number of frames in isp pool
- outputs: Number of frames in outputs pools
Returns
Shared pointer to the camera node
function
std::shared_ptr< Camera > setMaxSizePools(int raw, int isp, int outputs)Set maximum memory size of all pools
Parameters
- raw: Maximum size in bytes of raw pool
- isp: Maximum size in bytes of isp pool
- outputs: Maximum size in bytes of outputs pools
Returns
Shared pointer to the camera node
function
std::shared_ptr< Camera > setOutputsNumFramesPool(int num)Set number of frames in pools for all outputs
Parameters
- num: Number of frames in pools for all outputs
Returns
Shared pointer to the camera node
function
std::shared_ptr< Camera > setOutputsMaxSizePool(int size)Set maximum size of pools for all outputs
Parameters
- size: Maximum size in bytes of pools for all outputs
Returns
Shared pointer to the camera node
function
int getRawNumFramesPool()Get number of frames in raw pool
Returns
Number of frames
function
int getMaxSizePoolRaw()Get maximum size of raw pool
Returns
Maximum size in bytes of raw pool
function
int getIspNumFramesPool()Get number of frames in isp pool
Returns
Number of frames
function
int getMaxSizePoolIsp()Get maximum size of isp pool
Returns
Maximum size in bytes of isp pool
function
std::optional< int > getOutputsNumFramesPool()Get number of frames in outputs pool for all outputs
Returns
Number of frames
function
std::optional< size_t > getOutputsMaxSizePool()Get maximum size of outputs pool for all outputs
Returns
Maximum size in bytes of image manip pool
function
Camera & setMockIsp(ReplayVideo & replay)Set mock ISP for Camera node. Automatically sets mockIsp size.
Parameters
- replay: ReplayVideo node to use as mock ISP
function
Camera()explicit function
Camera(std::shared_ptr< Device > & defaultDevice)explicit function
Camera(std::unique_ptr< Properties > props)function
void buildStage1()function
float getMaxRequestedFps()function
uint32_t getMaxRequestedWidth()function
uint32_t getMaxRequestedHeight()inline function
DeviceNodeCRTP()inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device)inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props)inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)需要帮助?
请前往 OAKChina 官网 获取技术支持或解答您的任何疑问。