| 143 | |
| 144 | |
| 145 | class OrbbecCamera(RgbdCamera): |
| 146 | backend = "orbbec" |
| 147 | |
| 148 | def __init__(self, *, info: DeviceInfo, width: int, height: int, fps: int): |
| 149 | self._info = dict(info) |
| 150 | self._width = int(width) |
| 151 | self._height = int(height) |
| 152 | self._fps = int(fps) |
| 153 | self._pipeline: Any | None = None |
| 154 | self._align_filter: Any | None = None |
| 155 | self._intrinsics: CameraIntrinsics | None = None |
| 156 | |
| 157 | @property |
| 158 | def info(self) -> DeviceInfo: |
| 159 | return dict(self._info) |
| 160 | |
| 161 | @property |
| 162 | def intrinsics(self) -> CameraIntrinsics: |
| 163 | if self._intrinsics is None: |
| 164 | raise RuntimeError("Orbbec camera has not been started") |
| 165 | return self._intrinsics |
| 166 | |
| 167 | def start(self) -> None: |
| 168 | ob = _ob() |
| 169 | device = _get_device(self._info) |
| 170 | pipeline = ob.Pipeline(device) |
| 171 | config = ob.Config() |
| 172 | |
| 173 | color_profile = pipeline.get_stream_profile_list(ob.OBSensorType.COLOR_SENSOR).get_video_stream_profile( |
| 174 | self._width, self._height, ob.OBFormat.RGB, self._fps |
| 175 | ) |
| 176 | depth_profile = pipeline.get_stream_profile_list(ob.OBSensorType.DEPTH_SENSOR).get_video_stream_profile( |
| 177 | self._width, self._height, ob.OBFormat.Y16, self._fps |
| 178 | ) |
| 179 | config.enable_stream(color_profile) |
| 180 | config.enable_stream(depth_profile) |
| 181 | config.set_frame_aggregate_output_mode(ob.OBFrameAggregateOutputMode.FULL_FRAME_REQUIRE) |
| 182 | |
| 183 | try: |
| 184 | pipeline.enable_frame_sync() |
| 185 | except Exception: |
| 186 | pass |
| 187 | |
| 188 | pipeline.start(config) |
| 189 | self._pipeline = pipeline |
| 190 | self._align_filter = ob.AlignFilter(align_to_stream=ob.OBStreamType.COLOR_STREAM) |
| 191 | self._intrinsics = CameraIntrinsics.from_orbbec(color_profile.get_intrinsic()) |
| 192 | self._info.update( |
| 193 | { |
| 194 | "width": str(self._width), |
| 195 | "height": str(self._height), |
| 196 | "fps": str(self._fps), |
| 197 | "depth_unit": "meter", |
| 198 | "depth_scale_m": f"{ORBBEC_DEPTH_SCALE_TO_METERS:.12g} * depth_frame.get_depth_scale()", |
| 199 | "color_format": "RGB", |
| 200 | "depth_format": "Y16", |
| 201 | "alignment": "software_depth_to_color", |
| 202 | } |