# Mono Camera

MonoCamera node is a source of [ImgFrame](https://docs.luxonis.com/software/depthai-components/messages/img_frame.md). You can
control in at runtime with the inputControl. Some DepthAI modules don't have mono camera(s). Two mono cameras are used to
calculate stereo depth (with [StereoDepth](https://docs.luxonis.com/software/depthai-components/nodes/stereo_depth.md) node).

## How to place it

#### Python

```python
pipeline = dai.Pipeline()
mono = pipeline.create(dai.node.MonoCamera)
```

#### C++

```cpp
dai::Pipeline pipeline;
auto mono = pipeline.create<dai::node::MonoCamera>();
```

## Inputs and Outputs

## Usage

#### Python

```python
pipeline = dai.Pipeline()
mono = pipeline.create(dai.node.MonoCamera)
mono.setCamera("right")
mono.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
```

#### C++

```cpp
dai::Pipeline pipeline;
auto mono = pipeline.create<dai::node::MonoCamera>();
mono->setCamera("right");
mono->setResolution(dai::MonoCameraProperties::SensorResolution::THE_720_P);
```

## 3A Algorithms

The 3A - Auto-Exposure (AE), Auto-White Balance (AWB), and Auto-Focus (AF) - algorithms are used to optimize image quality and run
directly on RVC. By default, these settings are in AUTO mode, with limits (e.g., min/max exposure) specific to each sensor (see
[supported sensors](https://docs.luxonis.com/hardware/platform/sensors/sensors.md) for details).

You can manually control these settings either by following the steps in [RGB camera control
example](https://docs.luxonis.com/software/depthai/examples/rgb_camera_control.md) or by using the [cam_test.py
script](https://github.com/luxonis/depthai-python/blob/main/utilities/cam_test.py).

 * Stereo Cameras: Sensors share the same I2C bus, ensuring synchronized 3A settings automatically (AWB, AE).
 * Independent Sensors: On setups like OAK FFC or OAK-D-LR, where each sensor has its own I2C, the 3a-follow feature can be used
   to synchronize 3A settings from one sensor to others.

Example Usage

```python
cam['cam_b'].initialControl.setMisc("3a-follow", dai.CameraBoardSocket.CAM_A)
cam['cam_c'].initialControl.setMisc("3a-follow", dai.CameraBoardSocket.CAM_A)
```

The 3a-follow feature copies the 3A settings (exposure, ISO, and white balance) from a primary camera (e.g., CAM_A) to other
cameras in the setup (e.g., CAM_B and CAM_C).

## Examples of functionality

 * [Mono Preview](https://docs.luxonis.com/software/depthai/examples/mono_preview.md)
 * [Mono & MobilenetSSD](https://docs.luxonis.com/software/depthai/examples/mono_depth_mobilenetssd.md)
 * [Mono Camera Control](https://docs.luxonis.com/software/depthai/examples/mono_camera_control.md)

## Reference

### depthai.node.MonoCamera(depthai.Node)

Kind: Class

MonoCamera node. For use with grayscale sensors.

#### getBoardSocket(self) -> depthai.CameraBoardSocket: depthai.CameraBoardSocket

Kind: Method

Retrieves which board socket to use

Returns:
Board socket to use

#### getCamId(self) -> int: int

Kind: Method

#### getCamera(self) -> str: str

Kind: Method

Retrieves which camera to use by name

Returns:
Name of the camera to use

#### getFps(self) -> float: float

Kind: Method

Get rate at which camera should produce frames

Returns:
Rate in frames per second

#### getFrameEventFilter(self) -> list[depthai.FrameEvent]: list[depthai.FrameEvent]

Kind: Method

#### getImageOrientation(self) -> depthai.CameraImageOrientation: depthai.CameraImageOrientation

Kind: Method

Get camera image orientation

#### getNumFramesPool(self) -> int: int

Kind: Method

Get number of frames in main (ISP output) pool

#### getRawNumFramesPool(self) -> int: int

Kind: Method

Get number of frames in raw pool

#### getResolution(self) -> depthai.MonoCameraProperties.SensorResolution: depthai.MonoCameraProperties.SensorResolution

Kind: Method

Get sensor resolution

#### getResolutionHeight(self) -> int: int

Kind: Method

Get sensor resolution height

#### getResolutionSize(self) -> tuple[int, int]: tuple[int, int]

Kind: Method

Get sensor resolution as size

#### getResolutionWidth(self) -> int: int

Kind: Method

Get sensor resolution width

#### setBoardSocket(self, boardSocket: depthai.CameraBoardSocket)

Kind: Method

Specify which board socket to use

Parameter ``boardSocket``:
Board socket to use

#### setCamId(self, arg0: typing.SupportsInt)

Kind: Method

#### setCamera(self, name: str)

Kind: Method

Specify which camera to use by name

Parameter ``name``:
Name of the camera to use

#### setFps(self, fps: typing.SupportsFloat)

Kind: Method

Set rate at which camera should produce frames

Parameter ``fps``:
Rate in frames per second

#### setFrameEventFilter(self, events: collections.abc.Sequence [ depthai.FrameEvent ])

Kind: Method

#### setImageOrientation(self, imageOrientation: depthai.CameraImageOrientation)

Kind: Method

Set camera image orientation

#### setIsp3aFps(self, isp3aFps: typing.SupportsInt)

Kind: Method

Isp 3A rate (auto focus, auto exposure, auto white balance, camera controls
etc.). Default (0) matches the camera FPS, meaning that 3A is running on each
frame. Reducing the rate of 3A reduces the CPU usage on CSS, but also increases
the convergence rate of 3A. Note that camera controls will be processed at this
rate. E.g. if camera is running at 30 fps, and camera control is sent at every
frame, but 3A fps is set to 15, the camera control messages will be processed at
15 fps rate, which will lead to queueing.

#### setNumFramesPool(self, arg0: typing.SupportsInt)

Kind: Method

Set number of frames in main (ISP output) pool

#### setRawNumFramesPool(self, arg0: typing.SupportsInt)

Kind: Method

Set number of frames in raw pool

#### setRawOutputPacked(self, packed: bool)

Kind: Method

Configures whether the camera `raw` frames are saved as MIPI-packed to memory.
The packed format is more efficient, consuming less memory on device, and less
data to send to host: RAW10: 4 pixels saved on 5 bytes, RAW12: 2 pixels saved on
3 bytes. When packing is disabled (`false`), data is saved lsb-aligned, e.g. a
RAW10 pixel will be stored as uint16, on bits 9..0: 0b0000'00pp'pppp'pppp.
Default is auto: enabled for standard color/monochrome cameras where ISP can
work with both packed/unpacked, but disabled for other cameras like ToF.

#### setResolution(self, resolution: depthai.MonoCameraProperties.SensorResolution)

Kind: Method

Set sensor resolution

#### frameEvent

Kind: Property

Outputs metadata-only ImgFrame message as an early indicator of an incoming
frame.

It's sent on the MIPI SoF (start-of-frame) event, just after the exposure of the
current frame has finished and before the exposure for next frame starts. Could
be used to synchronize various processes with camera capture. Fields populated:
camera id, sequence number, timestamp

#### initialControl

Kind: Property

Initial control options to apply to sensor

#### inputControl

Kind: Property

Input for CameraControl message, which can modify camera parameters in runtime
Default queue is blocking with size 8

#### out

Kind: Property

Outputs ImgFrame message that carries RAW8 encoded (grayscale) frame data.

Suitable for use StereoDepth node. Processed by ISP

#### raw

Kind: Property

Outputs ImgFrame message that carries RAW10-packed (MIPI CSI-2 format) frame
data.

Captured directly from the camera sensor

### Need assistance?

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