From 1866e5395737082c695a22c076fe6f1840d807f3 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Tue, 17 Oct 2023 16:03:56 +0800 Subject: [PATCH] ui.py: support strided buffer (#30236) fix crash --- tools/replay/ui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/replay/ui.py b/tools/replay/ui.py index 43195a481d..05e8bdec1f 100755 --- a/tools/replay/ui.py +++ b/tools/replay/ui.py @@ -116,9 +116,9 @@ def ui_thread(addr): if yuv_img_raw is None or not yuv_img_raw.data.any(): continue - imgff = np.frombuffer(yuv_img_raw.data, dtype=np.uint8).reshape((vipc_client.height * 3 // 2, vipc_client.width)) + imgff = np.frombuffer(yuv_img_raw.data, dtype=np.uint8).reshape((len(yuv_img_raw.data) // vipc_client.stride, vipc_client.stride)) num_px = vipc_client.width * vipc_client.height - bgr = cv2.cvtColor(imgff, cv2.COLOR_YUV2RGB_NV12) + bgr = cv2.cvtColor(imgff[:vipc_client.height * 3 // 2, :vipc_client.width], cv2.COLOR_YUV2RGB_NV12) zoom_matrix = _BB_TO_FULL_FRAME[num_px] cv2.warpAffine(bgr, zoom_matrix[:2], (img.shape[1], img.shape[0]), dst=img, flags=cv2.WARP_INVERSE_MAP)