From 90ae6e0b723e1573f75522b966437beb48b08dd0 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Tue, 26 Mar 2019 03:28:45 +0100 Subject: [PATCH] show image with confidence instead of grayscale --- cpp/sampleOpenCV/sampleOpenCV.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cpp/sampleOpenCV/sampleOpenCV.cpp b/cpp/sampleOpenCV/sampleOpenCV.cpp index ca4c208..93384ea 100644 --- a/cpp/sampleOpenCV/sampleOpenCV.cpp +++ b/cpp/sampleOpenCV/sampleOpenCV.cpp @@ -70,6 +70,7 @@ public : // each image containing one 32Bit channel zImage.create (Size (data->width, data->height), CV_32FC1); grayImage.create (Size (data->width, data->height), CV_32FC1); + confidenceImage.create (Size (data->width, data->height), CV_8UC1); // set the image to zero zImage = Scalar::all (0); @@ -80,9 +81,11 @@ public : { float *zRowPtr = zImage.ptr (y); float *grayRowPtr = grayImage.ptr (y); + uint8_t *confRowPtr = confidenceImage.ptr (y); for (int x = 0; x < zImage.cols; x++, k++) { auto curPoint = data->points.at (k); + confRowPtr[x] = curPoint.depthConfidence; if (curPoint.depthConfidence > confidence_threshold_) { // if the point is valid, map the pixel from 3D world @@ -157,10 +160,11 @@ public : } // scale and display the gray image - scaledGrayImage.create (Size (data->width * 4, data->height * 4), CV_8UC1); - resize (grayImage8, scaledGrayImage, scaledGrayImage.size()); + // scaledGrayImage.create (Size (data->width * 4, data->height * 4), CV_8UC1); + // resize (grayImage8, scaledGrayImage, scaledGrayImage.size()); + // imshow ("Gray", scaledGrayImage); - imshow ("Gray", scaledGrayImage); + imshow ("Confidence", confidenceImage); } void setLensParameters (const LensParameters &lensParameters) @@ -218,6 +222,7 @@ private: // and for their 8Bit and scaled versions Mat zImage, zImage8, scaledZImage; Mat grayImage, grayImage8, scaledGrayImage; + Mat confidenceImage; // lens matrices used for the undistortion of // the image @@ -319,7 +324,8 @@ int main (int argc, char *argv[]) // create two windows namedWindow ("Depth", WINDOW_AUTOSIZE); - namedWindow ("Gray", WINDOW_AUTOSIZE); + // namedWindow ("Gray", WINDOW_AUTOSIZE); + namedWindow ("Confidence", WINDOW_AUTOSIZE); // namedWindow ("column", WINDOW_AUTOSIZE); // start capture mode -- 1.7.10.4