From 202af3bb4e0360f79507f2f530df97100d2c9350 Mon Sep 17 00:00:00 2001 From: Maxime Desroches Date: Mon, 9 Aug 2021 03:43:11 -0400 Subject: [PATCH] tools: fix replay/camera.py crash (#21881) * check array size before reshape * revert * check length directly old-commit-hash: d90188a14e7f9a8e07850b4577cdaca037aa4903 --- tools/replay/camera.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/replay/camera.py b/tools/replay/camera.py index 9c1e9fb4b..d52395c25 100755 --- a/tools/replay/camera.py +++ b/tools/replay/camera.py @@ -66,8 +66,9 @@ def ui_thread(addr, frame_address): flags=cv2.WARP_INVERSE_MAP) else: # actually RGB - img = np.frombuffer(yuv_img, dtype=np.uint8).reshape((_FULL_FRAME_SIZE[1], _FULL_FRAME_SIZE[0], 3)) - img = img[:, :, ::-1] # Convert BGR to RGB + if len(yuv_img) != 0: + img = np.frombuffer(yuv_img, dtype=np.uint8).reshape((_FULL_FRAME_SIZE[1], _FULL_FRAME_SIZE[0], 3)) + img = img[:, :, ::-1] # Convert BGR to RGB height, width = img.shape[:2] img_resized = cv2.resize(