Skip to content

Commit

Permalink
Skip image that cannot be encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
haixuanTao committed Oct 10, 2024
1 parent ce408a1 commit 254e74d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion node-hub/opencv-video-capture/opencv_video_capture/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def main():
if encoding == "rgb8":
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
elif encoding in ["jpeg", "jpg", "jpe", "bmp", "webp", "png"]:
frame = cv2.imencode("." + encoding, frame)[1]
ret, frame = cv2.imencode("." + encoding, frame)
if not ret:
print("Could not encode image...")
continue

storage = pa.array(frame.ravel())

Expand Down

0 comments on commit 254e74d

Please sign in to comment.