diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2020-01-13 22:52:27 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2020-01-13 23:05:34 +0100 |
commit | b3b43a5216afbcaf5ed15fe73a5e156672cf6488 (patch) | |
tree | cc8d1b4707a8e134f2f237d0992acd8335c8d5fa | |
parent | c1ae0d8f66746cca27d6758d3fa2563204c4e8f5 (diff) |
tracker/kinect: sleep when identical frame receivedpr/kinect-block-frame
-rw-r--r-- | tracker-kinect-face/camera_kinect_ir.cpp | 18 | ||||
-rw-r--r-- | tracker-kinect-face/camera_kinect_ir.h | 3 |
2 files changed, 19 insertions, 2 deletions
diff --git a/tracker-kinect-face/camera_kinect_ir.cpp b/tracker-kinect-face/camera_kinect_ir.cpp index 81357a6d..024fd703 100644 --- a/tracker-kinect-face/camera_kinect_ir.cpp +++ b/tracker-kinect-face/camera_kinect_ir.cpp @@ -221,6 +221,7 @@ namespace Kinect { bool InfraredCamera::get_frame_(cv::Mat& aFrame) { + unsigned attempts = 0; if (!iInfraredFrameReader) { @@ -231,11 +232,26 @@ namespace Kinect { // Release previous frame if any SafeRelease(iInfraredFrame); - +start: HRESULT hr = iInfraredFrameReader->AcquireLatestFrame(&iInfraredFrame); if (SUCCEEDED(hr)) { + + { + TIMESPAN t = 0; + + (void)iInfraredFrame->get_RelativeTime(&t); + + if (t == timestamp && ++attempts < 10) + { + portable::sleep(2); + goto start; + } + + timestamp = t; + } + if (iFirstFrame) { IFrameDescription* frameDescription = NULL; diff --git a/tracker-kinect-face/camera_kinect_ir.h b/tracker-kinect-face/camera_kinect_ir.h index 83acb4d6..5dfb43bc 100644 --- a/tracker-kinect-face/camera_kinect_ir.h +++ b/tracker-kinect-face/camera_kinect_ir.h @@ -16,7 +16,7 @@ #include "compat/timer.hpp" #include "video/camera.hpp" - +#include <cinttypes> #include <memory> #include <opencv2/core.hpp> @@ -67,6 +67,7 @@ private: // ICoordinateMapper* iCoordinateMapper = nullptr; + std::int64_t timestamp = 0; video::frame iFrame; cv::Mat iMatFrame; |