feathersdk.robot.services.camera_service Module

class feathersdk.robot.services.camera_service.CameraResolution(value)

Bases: UniqueEnum

Resolution for the teleop camera.

HD720 = 0
HD1080 = 1
HD2K = 2
class feathersdk.robot.services.camera_service.CameraColorSpace(value)

Bases: UniqueEnum

The color space of the camera image output.

BGR = 0
RGB = 1
class feathersdk.robot.services.camera_service.ZedCameraVersion(value)

Bases: UniqueEnum

The version of the camera.

ZED_2i = 0
class feathersdk.robot.services.camera_service.BinocularCameraView(value)

Bases: UniqueEnum

The view of the binocular camera to use.

LEFT = 0
RIGHT = 1
BOTH = 2
class feathersdk.robot.services.camera_service.ZedCameraServiceConfig(*, module_name='camera_service', version=ZedCameraVersion.ZED_2i, resolution=CameraResolution.HD720, fps=30, view=BinocularCameraView.BOTH, color_space=CameraColorSpace.BGR, brightness=5, whitebalance_temp=5600)

Bases: PyDFrozenBaseModel

Configuration for the camera service.

Parameters:
module_name: str

The name of the module.

version: ZedCameraVersion

The version of the camera.

resolution: CameraResolution

The resolution of the camera.

fps: int

The frame rate of the camera.

view: BinocularCameraView

Whether to use just the left/right, or both cameras. The CameraService’s image will be the selected view.

color_space: CameraColorSpace

The color space of the camera image output.

brightness: int

The brightness of the camera.

whitebalance_temp: int

The white balance temperature of the camera.

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class feathersdk.robot.services.camera_service.ZedCameraService(config, *args, **kwargs)

Bases: RobotModule[ZedCameraServiceConfig]

A service that monitors the camera.

Parameters:
runtime_params: sl.RuntimeParameters

The runtime parameters for the zed camera.

width: int

The width in pixels of a single camera.

height: int

The height in pixels of the camera.

total_width: int

The total width in pixels of the camera. This is width * 2 if config.view == BinocularCameraView.BOTH, otherwise width.

image: ndarray

The image from the camera. If config.view == BinocularCameraView.BOTH, then this contains both left and right images in a side-by-side format. Will be in config.color_space format. Shape: (height, total_width, 3), dtype: np.uint8.

camera: sl.Camera | None

The ZED camera object.

init_params: sl.InitParameters

The initialization parameters for the zed camera.

get_imu_data()

Get the latest linear acceleration from the ZED 2i.

Values are in m/s^2 and include gravity. IMU frame: +X right of the camera, +Y down, +Z forward along the optical axis.

Return type:

Tuple[float, float, float]

get_imu_angular_velocity()

Get the latest angular velocity from the ZED 2i.

Values are in rad/s. IMU frame: +X right of the camera, +Y down, +Z forward.

Return type:

Tuple[float, float, float]

capture_image()

Capture an image from the camera, storing result in self.image.

Return type:

None

reset_camera()

Close and re-open the camera. Takes 5-10 seconds.

detect_broken_pipeline(apply_fix=True)

Detect (and possibly fix) if the camera pipeline is broken.

Sometimes, the camera pipeline will become broken due to a variety of reasons. For example, if the usb cable shakes and becomes loose for a second. When this happens, the resultant image will be homogenously colored.

This function will sample random pixels from the image. If the pixels are all the same, we assume that the pipeline is broken. If apply_fix is True, the function will attempt to fix the pipeline by closing and re-opening the camera (this will take 5-10 seconds), then capture a fresh image.

Parameters:

apply_fix (bool) – Whether to apply the fix to the camera pipeline.

Returns:

False if the camera pipeline is not broken, True otherwise. If apply_fix is True and the pipeline is broken, the function will return True and the pipeline will be reset.

Return type:

bool