From 51436cc320670e033c69bc01d2178bd245234670 Mon Sep 17 00:00:00 2001 From: Stéphane Lenclud Date: Sun, 14 Apr 2019 10:05:23 +0200 Subject: Kinect: IR camera now provides raw 16 bits buffer. Easy Tracker: Support for 16 bits and RGB frame buffers. --- tracker-easy/preview.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'tracker-easy/preview.cpp') diff --git a/tracker-easy/preview.cpp b/tracker-easy/preview.cpp index 404ad299..7f245ae4 100644 --- a/tracker-easy/preview.cpp +++ b/tracker-easy/preview.cpp @@ -19,18 +19,37 @@ namespace EasyTracker Preview& Preview::operator=(const cv::Mat& aFrame) { + //TODO: Assert if channel size is neither one nor two + + // Make sure our frame channel is 8 bit + size_t channelSize = aFrame.elemSize1(); + if (channelSize == 2) + { + // First resample to 8-bits + double min = std::numeric_limits::min(); + double max = std::numeric_limits::max(); + //cv::minMaxLoc(raw, &min, &max); // Should we use 16bit min and max instead? + // For scalling to have more precission in the range we are interrested in + //min = max - 255; + // See: https://stackoverflow.com/questions/14539498/change-type-of-mat-object-from-cv-32f-to-cv-8u/14539652 + aFrame.convertTo(iFrameChannelSizeOne, CV_8U, 255.0 / (max - min), -255.0*min / (max - min)); + } + else + { + iFrameChannelSizeOne = aFrame; + } // Make sure our frame is RGB // Make an extra copy if needed - int channelCount = aFrame.channels(); + int channelCount = iFrameChannelSizeOne.channels(); if (channelCount == 1) { // Convert to RGB - cv::cvtColor(aFrame, iFrameRgb, cv::COLOR_GRAY2BGR); + cv::cvtColor(iFrameChannelSizeOne, iFrameRgb, cv::COLOR_GRAY2BGR); } else if (channelCount == 3) { - iFrameRgb = aFrame; + iFrameRgb = iFrameChannelSizeOne; } else { -- cgit v1.2.3