summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tracker-kinect-face/camera_kinect_ir.cpp18
-rw-r--r--tracker-kinect-face/camera_kinect_ir.h3
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;