(self, camera_type = 'lit')
| 239 | time.sleep(2) |
| 240 | |
| 241 | def get_camera_data(self, camera_type = 'lit'): |
| 242 | valid_types = {'lit', 'object_mask', 'depth'} |
| 243 | if camera_type not in valid_types: |
| 244 | raise ValueError(f"Invalid camera type. Expected one of {valid_types}, but got '{camera_type}'.") |
| 245 | |
| 246 | if camera_type == 'lit': |
| 247 | data = self._client.request('vget /camera/1/lit png') |
| 248 | return cv2.imdecode(np.frombuffer(data, np.uint8), cv2.IMREAD_COLOR) |
| 249 | elif camera_type == 'object_mask': |
| 250 | data = self._client.request('vget /camera/1/object_mask png') |
| 251 | return cv2.imdecode(np.frombuffer(data, np.uint8), cv2.IMREAD_COLOR) |
| 252 | elif camera_type == 'depth': |
| 253 | data = self._client.request('vget /camera/1/depth npy') |
| 254 | depth_np = np.load(io.BytesIO(data)) |
| 255 | return depth_np # Return depth data |
| 256 | |
| 257 | def save_image(self, image_data, file_path): |
| 258 | cv2.imwrite(file_path, image_data) |
no test coverage detected