diff options
author | Stéphane Lenclud <github@lenclud.com> | 2019-03-18 16:52:19 +0100 |
---|---|---|
committer | Stéphane Lenclud <github@lenclud.com> | 2019-03-18 16:52:19 +0100 |
commit | f5a5777e2711ac342b9cab517ac3bfba0313bdaf (patch) | |
tree | e5db648eb4d79b332dcf02b4ed4f93c67572cc48 /tracker-pt/module | |
parent | 6d98d70ea4be87f8bf9a5304bd6defe795df21f9 (diff) |
Auto-reset when detecting absurd angles.kinect-point-tracker
Better buffer scaling to focus on the relevant part of our spectrum.
Diffstat (limited to 'tracker-pt/module')
-rw-r--r-- | tracker-pt/module/camera_kinect_ir.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tracker-pt/module/camera_kinect_ir.cpp b/tracker-pt/module/camera_kinect_ir.cpp index 2b3f389f..a798b65b 100644 --- a/tracker-pt/module/camera_kinect_ir.cpp +++ b/tracker-pt/module/camera_kinect_ir.cpp @@ -6,6 +6,9 @@ */ #include "camera_kinect_ir.h" + +#if __has_include(<Kinect.h>) + #include "frame.hpp" #include "compat/sleep.hpp" @@ -220,6 +223,7 @@ bool CameraKinectIr::get_frame_(cv::Mat& frame) IFrameDescription* frameDescription = NULL; int nWidth = 0; int nHeight = 0; + float diagonalFieldOfView = 0.0f; UINT nBufferSize = 0; UINT16 *pBuffer = NULL; @@ -242,6 +246,11 @@ bool CameraKinectIr::get_frame_(cv::Mat& frame) if (SUCCEEDED(hr)) { + hr = frameDescription->get_DiagonalFieldOfView(&diagonalFieldOfView); + } + + if (SUCCEEDED(hr)) + { hr = iInfraredFrame->AccessUnderlyingBuffer(&nBufferSize, &pBuffer); } @@ -255,8 +264,12 @@ bool CameraKinectIr::get_frame_(cv::Mat& frame) // Convert that OpenCV matrix to an RGB one as this is what is expected by our point extractor // TODO: Ideally we should implement a point extractors that works with our native buffer // First resample to 8-bits - double min, max; - cv::minMaxLoc(raw, &min, &max); // Should we use 16bit min and max instead? + double min = std::numeric_limits<uint16_t>::min(); + double max = std::numeric_limits<uint16_t>::max(); + // For scalling to have more precission in the range we are interrested in + min = max - 255; + //cv::minMaxLoc(raw, &min, &max); // Should we use 16bit min and max instead? + cv::Mat raw8; raw.convertTo(raw8, CV_8U, 255.0 / (max - min), -255.0*min / (max - min)); // Second convert to RGB @@ -302,3 +315,5 @@ void CameraKinectIr::camera_deleter::operator()(cv::VideoCapture* cap) } } // ns pt_module + +#endif |