diff --git a/README.md b/README.md index 0ac26e2..06ad1f3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This tutorial explains the "sampleOpenCV" which shows how you can use [OpenCV](h To run this sample you need to install a Royale binary version and additionaly the OpenCV library. This sample was tested with OpenCV version 4.6.0. After installing everything, you can start CMake. There you have to set the OpenCV_DIR to your OpenCV installation (e.g. C:/projects/opencv-4.6.0/opencv/build) -and the royale_DIR to the share folder of your Royale binary installation (e.g. D:\Program Files\royale\4.23.0.1062\share) and click **Generate**. +and the royale_DIR to the share folder of your Royale binary installation (e.g. D:\Program Files\royale\5.4.0.2112\lib\cmake) and click **Generate**. ## Code explanation In the beginning we declare a data listener and a camera device. We also declare the platform resources as this will call the CoInitializeEx function on Windows. Otherwise diff --git a/sampleOpenCV.cpp b/sampleOpenCV.cpp index 15eae6b..dfbf0ab 100644 --- a/sampleOpenCV.cpp +++ b/sampleOpenCV.cpp @@ -7,7 +7,6 @@ * PARTICULAR PURPOSE. * \****************************************************************************/ - #include #include #include @@ -67,13 +66,17 @@ public : float *grayRowPtr = grayImage.ptr (y); for (int x = 0; x < zImage.cols; x++, k++) { - auto curPoint = data->points.at (k); - if (curPoint.depthConfidence > 0) + auto curX = data->getX(k); + auto curY = data->getY(k); + auto curZ = data->getZ(k); + auto curConf = data->getDepthConfidence(k); + auto curGray = data->getGrayValue(k); + if (curConf > 0) { // if the point is valid, map the pixel from 3D world // coordinates to a 2D plane (this will distort the image) - zRowPtr[x] = adjustZValue (curPoint.z); - grayRowPtr[x] = static_cast (curPoint.grayValue); + zRowPtr[x] = adjustZValue (curZ); + grayRowPtr[x] = static_cast (curGray); } } } @@ -169,7 +172,7 @@ public : // the max dist here is used as an example and can be modified float adjustZValue (float zValue) { - float clampedDist = std::min (2.5f, zValue); + float clampedDist = std::min (2.5f, zValue); float newZValue = clampedDist / 2.5f * 255.0f; return newZValue; }