summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-03-28 09:22:06 +0100
committerStéphane Lenclud <github@lenclud.com>2019-03-28 17:45:05 +0100
commitd3445ae71743de358516d295294f4f569f1adfa5 (patch)
treeda49fba6770b767c9c407f1368d0dcc260f2e889
parent553d1a57244c1f8870dd3e83fbd9619a441db74b (diff)
tracker/kinect: get metadata only on first frame
-rw-r--r--tracker-kinect-face/camera_kinect_ir.cpp46
-rw-r--r--tracker-kinect-face/camera_kinect_ir.h4
2 files changed, 29 insertions, 21 deletions
diff --git a/tracker-kinect-face/camera_kinect_ir.cpp b/tracker-kinect-face/camera_kinect_ir.cpp
index 15bb7dca..f80eb73f 100644
--- a/tracker-kinect-face/camera_kinect_ir.cpp
+++ b/tracker-kinect-face/camera_kinect_ir.cpp
@@ -198,34 +198,40 @@ bool CameraKinectIr::get_frame_(cv::Mat& frame)
if (SUCCEEDED(hr))
{
INT64 nTime = 0;
- IFrameDescription* frameDescription = NULL;
- int nWidth = 0;
- int nHeight = 0;
- float diagonalFieldOfView = 0.0f;
UINT nBufferSize = 0;
UINT16 *pBuffer = NULL;
hr = iInfraredFrame->get_RelativeTime(&nTime);
- if (SUCCEEDED(hr))
+ if (first_frame)
{
- hr = iInfraredFrame->get_FrameDescription(&frameDescription);
- }
+ IFrameDescription* frameDescription = NULL;
- // TODO: should not request those info for a every frame really
- if (SUCCEEDED(hr))
- {
- hr = frameDescription->get_Width(&nWidth);
- }
+ if (SUCCEEDED(hr))
+ {
+ hr = iInfraredFrame->get_FrameDescription(&frameDescription);
+ }
- if (SUCCEEDED(hr))
- {
- hr = frameDescription->get_Height(&nHeight);
- }
+ // TODO: should not request those info for a every frame really
+ if (SUCCEEDED(hr))
+ {
+ hr = frameDescription->get_Width(&width);
+ }
- if (SUCCEEDED(hr))
- {
- hr = frameDescription->get_DiagonalFieldOfView(&diagonalFieldOfView);
+ if (SUCCEEDED(hr))
+ {
+ hr = frameDescription->get_Height(&height);
+ }
+
+ if (SUCCEEDED(hr))
+ {
+ hr = frameDescription->get_DiagonalFieldOfView(&fov);
+ }
+
+ if (SUCCEEDED(hr))
+ first_frame = false;
+
+ SafeRelease(frameDescription);
}
if (SUCCEEDED(hr))
@@ -255,8 +261,6 @@ bool CameraKinectIr::get_frame_(cv::Mat& frame)
//
success = true;
}
-
- SafeRelease(frameDescription);
}
diff --git a/tracker-kinect-face/camera_kinect_ir.h b/tracker-kinect-face/camera_kinect_ir.h
index cb525f72..d5b25baa 100644
--- a/tracker-kinect-face/camera_kinect_ir.h
+++ b/tracker-kinect-face/camera_kinect_ir.h
@@ -68,6 +68,10 @@ private:
video::frame iFrame;
cv::Mat iMatFrame;
cv::Mat raw8;
+
+ float fov = 0;
+ int width = 0, height = 0;
+ bool first_frame = true;
};
}