From 044fedd3446e95fa8bf95b28caacb6696d7b8452 Mon Sep 17 00:00:00 2001 From: Tuan Nghia Nguyen Date: Mon, 6 Jul 2026 21:39:39 +1000 Subject: [PATCH] ANSCV test: pump GUI messages while waiting for frames The empty-frame path slept 1 s without calling cv::waitKey, so the HighGUI window stopped pumping Windows messages and went "Not Responding" whenever the RTSP stream stalled for a few seconds. Wait via cv::waitKey(1000) instead (ESC still exits). Same fix in all three test loops that shared the pattern. Co-Authored-By: Claude Fable 5 --- tests/ANSCV-UnitTest/ANSCV-UnitTest.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/ANSCV-UnitTest/ANSCV-UnitTest.cpp b/tests/ANSCV-UnitTest/ANSCV-UnitTest.cpp index 71d435d..39897f8 100644 --- a/tests/ANSCV-UnitTest/ANSCV-UnitTest.cpp +++ b/tests/ANSCV-UnitTest/ANSCV-UnitTest.cpp @@ -887,7 +887,10 @@ int RSTPTestCVClient() { // ✅ Check if the image is valid BEFORE accessing it if (!image || image->empty()) { ANSCV_ReleaseImage_S(&image); - std::this_thread::sleep_for(std::chrono::seconds(1)); + // Wait via waitKey (not sleep) so the HighGUI window keeps pumping + // Windows messages — a raw sleep here makes the "Image" window go + // "Not Responding" whenever the stream stalls for a few seconds. + if (cv::waitKey(1000) == 27) break; continue; // Skip processing if the image is empty } @@ -1060,7 +1063,10 @@ int FPTestCVClient() { // ✅ Check if the image is valid BEFORE accessing it if (!image || image->empty()) { ANSCV_ReleaseImage_S(&image); - std::this_thread::sleep_for(std::chrono::seconds(1)); + // Wait via waitKey (not sleep) so the HighGUI window keeps pumping + // Windows messages — a raw sleep here makes the "Image" window go + // "Not Responding" whenever the stream stalls for a few seconds. + if (cv::waitKey(1000) == 27) break; continue; // Skip processing if the image is empty } @@ -1549,7 +1555,10 @@ int VideoPlayerClientTest() { // ✅ Check if the image is valid BEFORE accessing it if (!image || image->empty()) { ANSCV_ReleaseImage_S(&image); - std::this_thread::sleep_for(std::chrono::seconds(1)); + // Wait via waitKey (not sleep) so the HighGUI window keeps pumping + // Windows messages — a raw sleep here makes the "Image" window go + // "Not Responding" whenever the stream stalls for a few seconds. + if (cv::waitKey(1000) == 27) break; continue; // Skip processing if the image is empty }