CameraComponent

CameraComponent abstracts ColorCamera and MonoCamera nodes and supports mocking the camera when recording is passed during OakCamera initialization. When using Replaying feature, this component will mock the camera by sending frames from the host to the OAK device (via XLinkIn node).

Usage

from depthai_sdk import OakCamera

with OakCamera() as oak:
    # Create color camera
    color = oak.create_camera('color')

    # Visualize color camera frame stream
    oak.visualize(color.out.main, fps=True)
    # Start the pipeline, continuously poll
    oak.start(blocking=True)

Component outputs

  • main - Uses one of the outputs below.

  • camera - Default output. Streams either ColorCamera’s video (NV12) or MonoCamera’s out (GRAY8) frames. Produces FramePacket.

  • replay - If we are using Replaying feature. It doesn’t actually stream these frames back to the host, but rather sends read frames to syncing mechanism directly (to reduce bandwidth by avoiding loopback). Produces FramePacket.

  • encoded - If we are encoding frames, this will send encoded bitstream to the host. When visualized, it will decode frames (using cv2.imdecode for MJPEG, or pyav for H.26x). Produces FramePacket.

Reference

class depthai_sdk.components.CameraComponent(device, pipeline, source, resolution=None, fps=None, encode=None, sensor_type=None, rotation=None, replay=None, name=None, args=None)
on_pipeline_started(device)

This function gets called after the pipeline has been started. It is called from the main thread. It can be used to eg. initialize XlinkIn queues.

Parameters

device (depthai.Device) –

config_camera(size=None, resize_mode=<ResizeMode.CROP: 2>, fps=None, resolution=None)

Configure resolution, scale, FPS, etc.

Parameters
Return type

None

control_with_nn(detection_component, auto_focus=True, auto_exposure=True, debug=False)

Control the camera AF/AE/AWB based on the object detection results.

Parameters
  • detection_component (NNComponent) – NNComponent that will be used to control the camera

  • auto_focus – Enable auto focus to the object

  • auto_exposure – Enable auto exposure to the object

config_color_camera(interleaved=None, color_order=None, manual_focus=None, af_mode=None, awb_mode=None, scene_mode=None, anti_banding_mode=None, effect_mode=None, isp_scale=None, sharpness=None, luma_denoise=None, chroma_denoise=None)
Parameters
Return type

None

is_replay()
Return type

bool

is_color()
Return type

bool

is_mono()
Return type

bool

get_fps()
Return type

float

set_fps(fps)
Parameters

fps (float) –

config_encoder_h26x(rate_control_mode=None, keyframe_freq=None, bitrate_kbps=None, num_b_frames=None)
Parameters
config_encoder_mjpeg(quality=None, lossless=False)
Parameters
  • quality (Optional[int]) –

  • lossless (bool) –

get_stream_xout(fourcc=None)
Parameters

fourcc (Optional[str]) –

Return type

depthai_sdk.oak_outputs.xout.xout_base.StreamXout

set_num_frames_pool(num_frames, preview_num_frames=None)

Set the number of frames to be stored in the pool.

Parameters
  • num_frames (int) – Number of frames to be stored in the pool.

  • preview_num_frames (Optional[int]) – Number of frames to be stored in the pool for the preview stream.

get_fourcc()
Return type

Optional[str]

class Out(camera_component)
class CameraOut(component)
class ReplayOut(component)
class EncodedOut(component)