From 926593ab0f82b2fdfb44a2f2af1e181397d5e66e Mon Sep 17 00:00:00 2001 From: Timocop Date: Thu, 7 Apr 2022 08:00:34 +1200 Subject: [PATCH] limit grab frames --- .../PSMoveTracker/PSEye/PSEyeVideoCapture.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/psmoveservice/PSMoveTracker/PSEye/PSEyeVideoCapture.cpp b/src/psmoveservice/PSMoveTracker/PSEye/PSEyeVideoCapture.cpp index ea62bf78..d66a13b3 100644 --- a/src/psmoveservice/PSMoveTracker/PSEye/PSEyeVideoCapture.cpp +++ b/src/psmoveservice/PSMoveTracker/PSEye/PSEyeVideoCapture.cpp @@ -523,6 +523,14 @@ class PSEYECaptureCAM_VIRTUAL : public cv::IVideoCapture bool grabFrame() { + const std::chrono::time_point now = std::chrono::high_resolution_clock::now(); + const std::chrono::duration timeSinceLast = now - m_lastRequest; + if (timeSinceLast.count() < 2.f) + { + return true; + } + + m_lastRequest = now; if (capturePipe == INVALID_HANDLE_VALUE) { @@ -715,6 +723,7 @@ class PSEYECaptureCAM_VIRTUAL : public cv::IVideoCapture HANDLE capturePipe; char pipeBuffer[VRIT_BUFF_SIZE]; cv::Mat capFrame; + std::chrono::time_point m_lastRequest; }; static bool usingCLEyeDriver()