Skip to content

Commit c981b63

Browse files
committed
feat: allow also image formats with higher bit depth and preserve all channels
1 parent acef932 commit c981b63

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/arduino/app_peripherals/camera/websocket_camera.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async def _parse_message(self, message) -> Optional[np.ndarray]:
207207

208208
# Decode image
209209
nparr = np.frombuffer(image_data, np.uint8)
210-
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
210+
frame = cv2.imdecode(nparr, cv2.IMREAD_UNCHANGED)
211211
return frame
212212

213213
elif self.frame_format == "binary":
@@ -218,7 +218,7 @@ async def _parse_message(self, message) -> Optional[np.ndarray]:
218218
image_data = message
219219

220220
nparr = np.frombuffer(image_data, np.uint8)
221-
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
221+
frame = cv2.imdecode(nparr, cv2.IMREAD_UNCHANGED)
222222
return frame
223223

224224
elif self.frame_format == "json":
@@ -231,7 +231,7 @@ async def _parse_message(self, message) -> Optional[np.ndarray]:
231231
if "image" in data:
232232
image_data = base64.b64decode(data["image"])
233233
nparr = np.frombuffer(image_data, np.uint8)
234-
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
234+
frame = cv2.imdecode(nparr, cv2.IMREAD_UNCHANGED)
235235
return frame
236236

237237
elif "frame" in data:
@@ -240,7 +240,7 @@ async def _parse_message(self, message) -> Optional[np.ndarray]:
240240
if isinstance(frame_data, str):
241241
image_data = base64.b64decode(frame_data)
242242
nparr = np.frombuffer(image_data, np.uint8)
243-
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
243+
frame = cv2.imdecode(nparr, cv2.IMREAD_UNCHANGED)
244244
return frame
245245

246246
return None

0 commit comments

Comments
 (0)