From 254e74d4accb5cff13a29d1d9d01514863679842 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Thu, 10 Oct 2024 05:31:38 +0200 Subject: [PATCH] Skip image that cannot be encoded --- node-hub/opencv-video-capture/opencv_video_capture/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/node-hub/opencv-video-capture/opencv_video_capture/main.py b/node-hub/opencv-video-capture/opencv_video_capture/main.py index 71bc5edee..2e09b8159 100644 --- a/node-hub/opencv-video-capture/opencv_video_capture/main.py +++ b/node-hub/opencv-video-capture/opencv_video_capture/main.py @@ -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())