38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from dataclasses import dataclass
|
|
|
|
from ..configs import CameraConfig
|
|
|
|
|
|
@CameraConfig.register_subclass("opencv")
|
|
@dataclass
|
|
class OpenCVCameraConfig(CameraConfig):
|
|
"""
|
|
Example of tested options for Intel Real Sense D405:
|
|
|
|
```python
|
|
OpenCVCameraConfig(0, 30, 640, 480)
|
|
OpenCVCameraConfig(0, 60, 640, 480)
|
|
OpenCVCameraConfig(0, 90, 640, 480)
|
|
OpenCVCameraConfig(0, 30, 1280, 720)
|
|
```
|
|
"""
|
|
|
|
camera_index: int
|
|
fps: int | None = None
|
|
width: int | None = None
|
|
height: int | None = None
|
|
color_mode: str = "rgb"
|
|
channels: int | None = None
|
|
rotation: int | None = None
|
|
|
|
def __post_init__(self):
|
|
if self.color_mode not in ["rgb", "bgr"]:
|
|
raise ValueError(
|
|
f"`color_mode` is expected to be 'rgb' or 'bgr', but {self.color_mode} is provided."
|
|
)
|
|
|
|
self.channels = 3
|
|
|
|
if self.rotation not in [-90, None, 90, 180]:
|
|
raise ValueError(f"`rotation` must be in [-90, None, 90, 180] (got {self.rotation})")
|