# This is the CMakeCache file.
-# For build in directory: /home/bernhard/realraum/2019-03-letsCluster-Hackathon/libroyale-3.21.1.70-LINUX-x86-64Bit/samples/cpp/sampleMinMax
+# For build in directory: /mnt/201903hackathon/cpp/sampleMinMax
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# EXTERNAL cache entries
########################
-//Path to a program.
-CMAKE_AR:FILEPATH=/usr/bin/ar
-
-//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
-// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
-CMAKE_BUILD_TYPE:STRING=
-
-CMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF
-
-//Enable/Disable color output during build.
-CMAKE_COLOR_MAKEFILE:BOOL=ON
-
-//CXX compiler
-CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
-
-//A wrapper around 'ar' adding the appropriate '--plugin' option
-// for the GCC compiler
-CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-7
-
-//A wrapper around 'ranlib' adding the appropriate '--plugin' option
-// for the GCC compiler
-CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-7
-
-CMAKE_CXX_FLAGS:STRING= -fPIC -std=c++0x -Wall -Wconversion -fPIC -std=c++0x -Wall -Wconversion
-
-//Flags used by the compiler during debug builds.
-CMAKE_CXX_FLAGS_DEBUG:STRING=-g
-
-//Flags used by the compiler during release builds for minimum
-// size.
-CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
-
-//Flags used by the compiler during release builds.
-CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
-
-//Flags used by the compiler during release builds with debug info.
-CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
-
-//C compiler
-CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
-
-//A wrapper around 'ar' adding the appropriate '--plugin' option
-// for the GCC compiler
-CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-7
-
-//A wrapper around 'ranlib' adding the appropriate '--plugin' option
-// for the GCC compiler
-CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-7
-
-//Flags used by the compiler during all build types.
-CMAKE_C_FLAGS:STRING=
-
-//Flags used by the compiler during debug builds.
-CMAKE_C_FLAGS_DEBUG:STRING=-g
-
-//Flags used by the compiler during release builds for minimum
-// size.
-CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
-
-//Flags used by the compiler during release builds.
-CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
-
-//Flags used by the compiler during release builds with debug info.
-CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
-
-//Flags used by the linker.
-CMAKE_EXE_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//Enable/Disable output of compile commands during generation.
-CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
-
-//Install path prefix, prepended onto install directories.
-CMAKE_INSTALL_PREFIX:PATH=/usr/local
-
-CMAKE_INSTALL_RPATH:STRING=$ORIGIN/
-
-//Path to a program.
-CMAKE_LINKER:FILEPATH=/usr/bin/ld
-
-//Path to a program.
-CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
-
-//Flags used by the linker during the creation of modules.
-CMAKE_MODULE_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//Path to a program.
-CMAKE_NM:FILEPATH=/usr/bin/nm
-
-//Path to a program.
-CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
-
-//Path to a program.
-CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
-
-//Value Computed by CMake
-CMAKE_PROJECT_NAME:STATIC=sampleMinMax
-
-//Path to a program.
-CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
-
-//Flags used by the linker during the creation of dll's.
-CMAKE_SHARED_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//If set, runtime paths are not added when installing shared libraries,
-// but are added when building.
-CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
-
-//If set, runtime paths are not added when using shared libraries.
-CMAKE_SKIP_RPATH:BOOL=NO
-
-//Flags used by the linker during the creation of static libraries.
-CMAKE_STATIC_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//Path to a program.
-CMAKE_STRIP:FILEPATH=/usr/bin/strip
-
-//If this value is on, makefiles will be generated without the
-// .SILENT directive, and all commands will be echoed to the console
-// during the make. This is useful for debugging only. With Visual
-// Studio IDE projects all commands are done without /nologo.
-CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
-
-royale_CONFIG_PATH:FILEPATH=/home/bernhard/realraum/2019-03-letsCluster-Hackathon/libroyale-3.21.1.70-LINUX-x86-64Bit/share
-
//The directory containing a CMake configuration file for royale.
-royale_DIR:PATH=/home/bernhard/realraum/2019-03-letsCluster-Hackathon/libroyale-3.21.1.70-LINUX-x86-64Bit/share
-
-//Path where Royale libraries are located
-royale_LIB_DIR:PATH=
-
-//Value Computed by CMake
-sampleMinMax_BINARY_DIR:STATIC=/home/bernhard/realraum/2019-03-letsCluster-Hackathon/libroyale-3.21.1.70-LINUX-x86-64Bit/samples/cpp/sampleMinMax
-
-//Value Computed by CMake
-sampleMinMax_SOURCE_DIR:STATIC=/home/bernhard/realraum/2019-03-letsCluster-Hackathon/libroyale-3.21.1.70-LINUX-x86-64Bit/samples/cpp/sampleMinMax
+royale_DIR:PATH=royale_DIR-NOTFOUND
########################
# INTERNAL cache entries
########################
-//ADVANCED property for variable: CMAKE_AR
-CMAKE_AR-ADVANCED:INTERNAL=1
//This is the directory where this CMakeCache.txt was created
-CMAKE_CACHEFILE_DIR:INTERNAL=/home/bernhard/realraum/2019-03-letsCluster-Hackathon/libroyale-3.21.1.70-LINUX-x86-64Bit/samples/cpp/sampleMinMax
+CMAKE_CACHEFILE_DIR:INTERNAL=/mnt/201903hackathon/cpp/sampleMinMax
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache
-CMAKE_CACHE_MINOR_VERSION:INTERNAL=10
+CMAKE_CACHE_MINOR_VERSION:INTERNAL=9
//Patch version of cmake used to create the current loaded cache
-CMAKE_CACHE_PATCH_VERSION:INTERNAL=2
-//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
-CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
+CMAKE_CACHE_PATCH_VERSION:INTERNAL=1
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
-//ADVANCED property for variable: CMAKE_CXX_COMPILER
-CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_COMPILER_AR
-CMAKE_CXX_COMPILER_AR-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_COMPILER_RANLIB
-CMAKE_CXX_COMPILER_RANLIB-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS
-CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
-CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
-CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
-CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
-CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_COMPILER
-CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_COMPILER_AR
-CMAKE_C_COMPILER_AR-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_COMPILER_RANLIB
-CMAKE_C_COMPILER_RANLIB-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS
-CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
-CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
-CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
-CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
-CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//Executable file format
-CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
-CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
-CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
-CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
-CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
-CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
//Name of external makefile project generator.
CMAKE_EXTRA_GENERATOR:INTERNAL=
//Name of generator.
CMAKE_GENERATOR_TOOLSET:INTERNAL=
//Source directory with the top level CMakeLists.txt file for this
// project
-CMAKE_HOME_DIRECTORY:INTERNAL=/home/bernhard/realraum/2019-03-letsCluster-Hackathon/libroyale-3.21.1.70-LINUX-x86-64Bit/samples/cpp/sampleMinMax
-//Install .so files without execute permission.
-CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1
-//ADVANCED property for variable: CMAKE_LINKER
-CMAKE_LINKER-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
-CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
-CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
-CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
-CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
-CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_NM
-CMAKE_NM-ADVANCED:INTERNAL=1
+CMAKE_HOME_DIRECTORY:INTERNAL=/mnt/201903hackathon/cpp/sampleMinMax
//number of local generators
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
-//ADVANCED property for variable: CMAKE_OBJCOPY
-CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_OBJDUMP
-CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
-//Platform information initialized
-CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_RANLIB
-CMAKE_RANLIB-ADVANCED:INTERNAL=1
//Path to CMake installation.
-CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.10
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
-CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
-CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
-CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
-CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
-CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SKIP_RPATH
-CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
-CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
-CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
-CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
-CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STRIP
-CMAKE_STRIP-ADVANCED:INTERNAL=1
-//uname command
-CMAKE_UNAME:INTERNAL=/bin/uname
-//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
-CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: royale_CONFIG_PATH
-royale_CONFIG_PATH-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: royale_LIB_DIR
-royale_LIB_DIR-ADVANCED:INTERNAL=1
+CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.9
--- /dev/null
+/****************************************************************************\
+ * Copyright (C) 2017 Infineon Technologies & pmdtechnologies ag
+ *
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ \****************************************************************************/
+
+#include <royale.hpp>
+#include <iostream>
+#include <mutex>
+#include <opencv2/opencv.hpp>
+
+#include <sample_utils/PlatformResources.hpp>
+
+using namespace royale;
+using namespace sample_utils;
+using namespace std;
+using namespace cv;
+
+// Linker errors for the OpenCV sample
+//
+// If this example gives linker errors about undefined references to cv::namedWindow and cv::imshow,
+// or QFontEngine::glyphCache and qMessageFormatString (from OpenCV to Qt), it may be caused by a
+// change in the compiler's C++ ABI.
+//
+// With Ubuntu and Debian's distribution packages, the libopencv packages that have 'v5' at the end
+// of their name, for example libopencv-video2.4v5, are compatible with GCC 5 (and GCC 6), but
+// incompatible with GCC 4.8 and GCC 4.9. The -dev packages don't have the postfix, but depend on
+// the v5 (or non-v5) version of the corresponding lib package. When Ubuntu moves to OpenCV 3.0,
+// they're likely to drop the postfix (but the packages will be for GCC 5 or later).
+//
+// If you are manually installing OpenCV or Qt, you need to ensure that the binaries were compiled
+// with the same version of the compiler. The version number of the packages themselves doesn't say
+// which ABI they use, it depends on which version of the compiler was used.
+
+class MyListener : public IDepthDataListener
+{
+
+public :
+
+ MyListener() :
+ undistortImage (false)
+ {
+ }
+
+ void onNewData (const DepthData *data)
+ {
+ // this callback function will be called for every new
+ // depth frame
+
+ std::lock_guard<std::mutex> lock (flagMutex);
+
+ // create two images which will be filled afterwards
+ // each image containing one 32Bit channel
+ zImage.create (Size (data->width, data->height), CV_32FC1);
+ grayImage.create (Size (data->width, data->height), CV_32FC1);
+
+ // set the image to zero
+ zImage = Scalar::all (0);
+ grayImage = Scalar::all (0);
+
+ int k = 0;
+ for (int y = 0; y < zImage.rows; y++)
+ {
+ float *zRowPtr = zImage.ptr<float> (y);
+ float *grayRowPtr = grayImage.ptr<float> (y);
+ for (int x = 0; x < zImage.cols; x++, k++)
+ {
+ auto curPoint = data->points.at (k);
+ if (curPoint.depthConfidence > 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] = adjustGrayValue (curPoint.grayValue);
+ }
+ }
+ }
+
+ // create images to store the 8Bit version (some OpenCV
+ // functions may only work on 8Bit images)
+ zImage8.create (Size (data->width, data->height), CV_8UC1);
+ grayImage8.create (Size (data->width, data->height), CV_8UC1);
+
+ // convert images to the 8Bit version
+ // This sample uses a fixed scaling of the values to (0, 255) to avoid flickering.
+ // You can also replace this with an automatic scaling by using
+ // normalize(zImage, zImage8, 0, 255, NORM_MINMAX, CV_8UC1)
+ // normalize(grayImage, grayImage8, 0, 255, NORM_MINMAX, CV_8UC1)
+ zImage.convertTo (zImage8, CV_8UC1);
+ grayImage.convertTo (grayImage8, CV_8UC1);
+
+ if (undistortImage)
+ {
+ // call the undistortion function on the z image
+ Mat temp = zImage8.clone();
+ undistort (temp, zImage8, cameraMatrix, distortionCoefficients);
+ }
+
+ // scale and display the depth image
+ scaledZImage.create (Size (data->width * 4, data->height * 4), CV_8UC1);
+ resize (zImage8, scaledZImage, scaledZImage.size());
+
+ imshow ("Depth", scaledZImage);
+
+ if (undistortImage)
+ {
+ // call the undistortion function on the gray image
+ Mat temp = grayImage8.clone();
+ undistort (temp, grayImage8, cameraMatrix, distortionCoefficients);
+ }
+
+ // scale and display the gray image
+ scaledGrayImage.create (Size (data->width * 4, data->height * 4), CV_8UC1);
+ resize (grayImage8, scaledGrayImage, scaledGrayImage.size());
+
+ imshow ("Gray", scaledGrayImage);
+ }
+
+ void setLensParameters (const LensParameters &lensParameters)
+ {
+ // Construct the camera matrix
+ // (fx 0 cx)
+ // (0 fy cy)
+ // (0 0 1 )
+ cameraMatrix = (Mat1d (3, 3) << lensParameters.focalLength.first, 0, lensParameters.principalPoint.first,
+ 0, lensParameters.focalLength.second, lensParameters.principalPoint.second,
+ 0, 0, 1);
+
+ // Construct the distortion coefficients
+ // k1 k2 p1 p2 k3
+ distortionCoefficients = (Mat1d (1, 5) << lensParameters.distortionRadial[0],
+ lensParameters.distortionRadial[1],
+ lensParameters.distortionTangential.first,
+ lensParameters.distortionTangential.second,
+ lensParameters.distortionRadial[2]);
+ }
+
+ void toggleUndistort()
+ {
+ std::lock_guard<std::mutex> lock (flagMutex);
+ undistortImage = !undistortImage;
+ }
+
+private:
+
+ // adjust z value to fit fixed scaling, here max dist is 2.5m
+ // 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 newZValue = clampedDist / 2.5f * 255.0f;
+ return newZValue;
+ }
+
+ // adjust gray value to fit fixed scaling, here max value is 180
+ // the max value here is used as an example and can be modified
+ float adjustGrayValue (uint16_t grayValue)
+ {
+ float clampedVal = std::min (180.0f, grayValue * 1.0f);
+ float newGrayValue = clampedVal / 180.f * 255.0f;
+ return newGrayValue;
+ }
+
+ // define images for depth and gray
+ // and for their 8Bit and scaled versions
+ Mat zImage, zImage8, scaledZImage;
+ Mat grayImage, grayImage8, scaledGrayImage;
+
+ // lens matrices used for the undistortion of
+ // the image
+ Mat cameraMatrix;
+ Mat distortionCoefficients;
+
+ std::mutex flagMutex;
+ bool undistortImage;
+};
+
+int main (int argc, char *argv[])
+{
+ // Windows requires that the application allocate these, not the DLL.
+ PlatformResources resources;
+
+ // This is the data listener which will receive callbacks. It's declared
+ // before the cameraDevice so that, if this function exits with a 'return'
+ // statement while the camera is still capturing, it will still be in scope
+ // until the cameraDevice's destructor implicitly de-registers the listener.
+ MyListener listener;
+
+ // this represents the main camera device object
+ std::unique_ptr<ICameraDevice> cameraDevice;
+
+ // the camera manager will query for a connected camera
+ {
+ CameraManager manager;
+
+ // check the number of arguments
+ if (argc > 1)
+ {
+ // if the program was called with an argument try to open this as a file
+ cout << "Trying to open : " << argv[1] << endl;
+ cameraDevice = manager.createCamera (argv[1]);
+ }
+ else
+ {
+ // if no argument was given try to open the first connected camera
+ royale::Vector<royale::String> camlist (manager.getConnectedCameraList());
+ cout << "Detected " << camlist.size() << " camera(s)." << endl;
+
+ if (!camlist.empty())
+ {
+ cameraDevice = manager.createCamera (camlist[0]);
+ }
+ else
+ {
+ cerr << "No suitable camera device detected." << endl
+ << "Please make sure that a supported camera is plugged in, all drivers are "
+ << "installed, and you have proper USB permission" << endl;
+ return 1;
+ }
+
+ camlist.clear();
+ }
+ }
+ // the camera device is now available and CameraManager can be deallocated here
+
+ if (cameraDevice == nullptr)
+ {
+ // no cameraDevice available
+ if (argc > 1)
+ {
+ cerr << "Could not open " << argv[1] << endl;
+ return 1;
+ }
+ else
+ {
+ cerr << "Cannot create the camera device" << endl;
+ return 1;
+ }
+ }
+
+ // IMPORTANT: call the initialize method before working with the camera device
+ auto status = cameraDevice->initialize();
+ if (status != CameraStatus::SUCCESS)
+ {
+ cerr << "Cannot initialize the camera device, error string : " << getErrorString (status) << endl;
+ return 1;
+ }
+
+ // retrieve the lens parameters from Royale
+ LensParameters lensParameters;
+ status = cameraDevice->getLensParameters (lensParameters);
+ if (status != CameraStatus::SUCCESS)
+ {
+ cerr << "Can't read out the lens parameters" << endl;
+ return 1;
+ }
+
+ listener.setLensParameters (lensParameters);
+
+ // register a data listener
+ if (cameraDevice->registerDataListener (&listener) != CameraStatus::SUCCESS)
+ {
+ cerr << "Error registering data listener" << endl;
+ return 1;
+ }
+
+ // create two windows
+ namedWindow ("Depth", WINDOW_AUTOSIZE);
+ namedWindow ("Gray", WINDOW_AUTOSIZE);
+
+ // start capture mode
+ if (cameraDevice->startCapture() != CameraStatus::SUCCESS)
+ {
+ cerr << "Error starting the capturing" << endl;
+ return 1;
+ }
+
+ int currentKey = 0;
+
+ while (currentKey != 27)
+ {
+ // wait until a key is pressed
+ currentKey = waitKey (0) & 255;
+
+ if (currentKey == 'd')
+ {
+ // toggle the undistortion of the image
+ listener.toggleUndistort();
+ }
+ }
+
+ // stop capture mode
+ if (cameraDevice->stopCapture() != CameraStatus::SUCCESS)
+ {
+ cerr << "Error stopping the capturing" << endl;
+ return 1;
+ }
+
+ return 0;
+}