# Camera

`Camera` is a single, unified source node that replaces the separate
[ColorCamera](article://software-v3.depthai.depthai-components.nodes.color_camera) and
[MonoCamera](article://software-v3.depthai.depthai-components.nodes.mono_camera) nodes. It produces
[`ImgFrame`](https://docs.luxonis.com/software-v3/depthai/depthai-components/messages/img_frame.md) messages which can be used for
image processing and neural network inference.

## Key Features

 * Auto‑selection of sensor resolution & FPS when you don’t specify them — no more manual bookkeeping.
 * `requestOutput()`

```py
cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
                resize_mode=dai.ImgResizeMode.CROP,
                enableUndistortion=True,
                alphaScaling=0.0)
```

 * Undistortion is opt-in per output via `enableUndistortion` (default = `False`). It is not applied automatically to any stream.
 * When undistortion is enabled, `alphaScaling` optionally controls the balance between cropping and retaining the full field of
   view.
 * Undistortion does not change the stored camera intrinsics; the effective FOV still depends on the requested output size, resize
   mode, and `alphaScaling` value.
 * Runtime exposure control through
   [`CameraControl`](https://docs.luxonis.com/software-v3/depthai/depthai-components/messages/camera_control.md), including
   `setAutoExposureMaxISO()` when you want auto exposure to stay below a chosen ISO ceiling.
 * `requestFullResolutionOutput()` with safety guard (stays ≤ 5 K×4 K unless you pass `useHighestResolution=True`).
 * `setMockIsp()` for synthetic or recorded inputs (attach a `ReplayVideo` node to feed pre‑captured frames).

Upgrading from `ColorCamera` or `MonoCamera`? Just search‑and‑replace the node creation and delete any manual `setIspScale()`
logic.

## Placing the node

#### Python

```python
with dai.Pipeline() as pipeline:
    cam = pipeline.create(dai.node.Camera)
    cam.build(dai.CameraBoardSocket.CAM_A)  # optional — autodetects otherwise
```

#### C++

```cpp
// C++
dai::Pipeline pipeline;
auto cam = pipeline.create<dai::node::Camera>();
cam->build(dai::CameraBoardSocket::CAM_A);
```

## Inputs & Outputs

### Resizing modes

 * Crop: No NN accuracy decrease. Cons: Frame is cropped, so it's not full FOV.
 * Letterbox: Preserves full FOV. Cons: Smaller "frame" means less features might decrease NN accuracy.
 * Stretch: Preserves full FOV. Cons: Due to stretched frames, NNs accuracy might decrease.

```python
cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
                resize_mode=dai.ImgResizeMode.CROP)
cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
                resize_mode=dai.ImgResizeMode.RESIZE)
cam.requestOutput(size=(640, 480), type=dai.ImgFrame.Type.NV12,
                resize_mode=dai.ImgResizeMode.LETTERBOX)
```

## Usage Examples

#### Python

```python
pipeline = dai.Pipeline()

cam = pipeline.create(dai.node.Camera)
cam.build(boardSocket=dai.CameraBoardSocket.CAM_A)

# 1) Low‑latency preview for video encoder
nn_in = cam.requestOutput(size=(300,300), type=dai.ImgFrame.Type.NV12, fps=30)

# 2) HD stream for recording
hd_out = cam.requestOutput(size=(1280,720), type=dai.ImgFrame.Type.BGR888p, fps=30)

# 3) Full‑res stills every second
full = cam.requestFullResolutionOutput(type=dai.ImgFrame.Type.BGR888p, fps=1)

# Link to downstream nodes …
```

#### C++

```cpp
auto cam = pipeline.create<dai::node::Camera>();
cam->build(dai::CameraBoardSocket::CAM_A);

auto nnIn  = cam->requestOutput({300, 300}, dai::ImgFrame::Type::NV12,
                                dai::ImgResizeMode::CROP, 30);
auto hdOut = cam->requestOutput({1280,720}, dai::ImgFrame::Type::BGR888p,
                                dai::ImgResizeMode::STRETCH, 30);
auto full  = cam->requestFullResolutionOutput(dai::ImgFrame::Type::BGR888p, 1);
```

## Auto exposure ISO ceiling

When auto exposure is enabled, you can cap the maximum ISO that the camera is allowed to use. This is useful in low-light scenes
where you want to limit sensor gain and keep image noise under control.

#### Python

```python
control_q = cam.inputControl.createInputQueue()

ctrl = dai.CameraControl()
ctrl.setAutoExposureMaxISO(800)
control_q.send(ctrl)
```

#### C++

```cpp
auto controlQ = cam->inputControl.createInputQueue();

dai::CameraControl ctrl;
ctrl.setAutoExposureMaxISO(800);
controlQ->send(ctrl);
```

## Platform-Specific Limits

#### RVC2

ISP ~ 600 MP/s sustained (≈ 4 K @ 30 fps) → budget accordingly when running heavy NNs and video encoder. 3A runs on the embedded
micro-DSP and tops out at ~ 250 fps aggregated across all camera streams.

#### RVC4

With Luxonis OS 1.44.0 or newer, IFE sharing supports up to five concurrent camera sensors at up to 2.3 Gpix/s aggregate
processing. Configurations include two 48MP cameras at up to 6.5 FPS each plus three cameras at 20MP or lower, or one 48MP camera
at up to 13.5 FPS plus four cameras at 20MP or lower.

See [RVC4 ISP specifications](https://docs.luxonis.com/hardware/platform/rvc/rvc4.md)

## Further Examples

 * [Camera Output](https://docs.luxonis.com/software-v3/depthai/examples/camera/camera_output.md)
 * [Camera ISP Output](https://docs.luxonis.com/software-v3/depthai/examples/camera/camera_isp.md)
 * [Multiple Outputs](https://docs.luxonis.com/software-v3/depthai/examples/camera/camera_all.md)
 * [Undistort Stream](https://docs.luxonis.com/software-v3/depthai/examples/camera/camera_undistort.md)

## API Reference

### dai::node::Camera

Kind: class

#### CameraControl initialControl

Kind: variable

Initial control options to apply to sensor

#### Input inputControl

Kind: variable

Input for CameraControl message, which can modify camera parameters in runtime

#### Input mockIsp

Kind: variable

Input for mocking 'isp' functionality on RVC2. Default queue is blocking with size 8

#### Output raw

Kind: variable

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.

#### OutputMap dynamicOutputs

Kind: variable

#### 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, std::optional< float > alphaScaling)

Kind: function

Get video output with specified size.

#### Node::Output * requestOutput(const Capability & capability, bool onHost)

Kind: function

Request output with advanced controls. Mainly to be used by custom node writers.

#### Node::Output * requestFullResolutionOutput(std::optional< ImgFrame::Type > type, std::optional< float > fps, bool useHighestResolution)

Kind: function

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

#### Node::Output * requestIspOutput(std::optional< float > fps)

Kind: function

Request output with isp resolution. The fps does not vote.

#### std::shared_ptr< Camera > build(dai::CameraBoardSocket boardSocket, const std::optional< std::pair< uint32_t, uint32_t >> & sensorResolution, std::optional< float > sensorFps)

Kind: function

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)

#### std::shared_ptr< Camera > setSensorType(CameraSensorType sensorType)

Kind: function

Set the sensor type to use parameters: sensorType: Sensor type to use

#### CameraSensorType getSensorType()

Kind: function

Get the sensor type return: Sensor type

#### std::shared_ptr< Camera > setImageOrientation(CameraImageOrientation imageOrientation)

Kind: function

Set camera image orientation parameters: imageOrientation: Image orientation to set return: Shared pointer to the camera node

#### CameraImageOrientation getImageOrientation()

Kind: function

Get camera image orientation return: Image orientation

#### std::shared_ptr< Camera > build(dai::CameraBoardSocket boardSocket, ReplayVideo & replay)

Kind: function

Build with a specific board socket and mock input

#### std::shared_ptr< Camera > build(ReplayVideo & replay)

Kind: function

Build with mock input

#### uint32_t getMaxWidth()

Kind: function

Get max width of the camera (can only be called after build)

#### uint32_t getMaxHeight()

Kind: function

Get max height of the camera (can only be called after build)

#### CameraBoardSocket getBoardSocket()

Kind: function

Retrieves which board socket to use return: Board socket to use

#### std::shared_ptr< Camera > setRawNumFramesPool(int num)

Kind: function

Set number of frames in raw pool (will be automatically reduced if the maximum pool memory size is exceeded) parameters: num:
Number of frames return: Shared pointer to the camera node

#### std::shared_ptr< Camera > setMaxSizePoolRaw(int size)

Kind: function

Set maximum size of raw pool parameters: size: Maximum size in bytes of raw pool return: Shared pointer to the camera node

#### std::shared_ptr< Camera > setIspNumFramesPool(int num)

Kind: function

Set number of frames in isp pool (will be automatically reduced if the maximum pool memory size is exceeded) parameters: num:
Number of frames return: Shared pointer to the camera node

#### std::shared_ptr< Camera > setMaxSizePoolIsp(int size)

Kind: function

Set maximum size of isp pool parameters: size: Maximum size in bytes of isp pool return: Shared pointer to the camera node

#### std::shared_ptr< Camera > setNumFramesPools(int raw, int isp, int outputs)

Kind: function

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 return: Shared pointer
to the camera node

#### std::shared_ptr< Camera > setMaxSizePools(int raw, int isp, int outputs)

Kind: function

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 return: Shared pointer to the camera node

#### std::shared_ptr< Camera > setOutputsNumFramesPool(int num)

Kind: function

Set number of frames in pools for all outputs parameters: num: Number of frames in pools for all outputs return: Shared pointer to
the camera node

#### std::shared_ptr< Camera > setOutputsMaxSizePool(int size)

Kind: function

Set maximum size of pools for all outputs parameters: size: Maximum size in bytes of pools for all outputs return: Shared pointer
to the camera node

#### int getRawNumFramesPool()

Kind: function

Get number of frames in raw pool return: Number of frames

#### int getMaxSizePoolRaw()

Kind: function

Get maximum size of raw pool return: Maximum size in bytes of raw pool

#### int getIspNumFramesPool()

Kind: function

Get number of frames in isp pool return: Number of frames

#### int getMaxSizePoolIsp()

Kind: function

Get maximum size of isp pool return: Maximum size in bytes of isp pool

#### std::optional< int > getOutputsNumFramesPool()

Kind: function

Get number of frames in outputs pool for all outputs return: Number of frames

#### std::optional< size_t > getOutputsMaxSizePool()

Kind: function

Get maximum size of outputs pool for all outputs return: Maximum size in bytes of image manip pool

#### Camera & setMockIsp(ReplayVideo & replay)

Kind: function

Set mock ISP for Camera node. Automatically sets mockIsp size. parameters: replay: ReplayVideo node to use as mock ISP

#### Camera()

Kind: function

#### Camera(std::shared_ptr< Device > & defaultDevice)

Kind: function

#### Camera(std::unique_ptr< Properties > props)

Kind: function

#### void buildStage1()

Kind: function

Build stages;.

#### float getMaxRequestedFps()

Kind: function

#### uint32_t getMaxRequestedWidth()

Kind: function

#### uint32_t getMaxRequestedHeight()

Kind: function

#### DeviceNodeCRTP()

Kind: function

#### DeviceNodeCRTP(const std::shared_ptr< Device > & device)

Kind: function

#### DeviceNodeCRTP(std::unique_ptr< Properties > props)

Kind: function

#### DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)

Kind: function

#### DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)

Kind: function

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
