From 9370811966aa37effdfe52ffe895ac29e39c147b Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 25 Apr 2024 10:08:37 +0200 Subject: [PATCH 1/5] Display color instead of gray images --- .../device/framegrabber/saveRealSenseData.cpp | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/example/device/framegrabber/saveRealSenseData.cpp b/example/device/framegrabber/saveRealSenseData.cpp index 5db5e390fa..13b03dde2f 100644 --- a/example/device/framegrabber/saveRealSenseData.cpp +++ b/example/device/framegrabber/saveRealSenseData.cpp @@ -60,7 +60,6 @@ #endif #include -#include #include #include #include @@ -132,6 +131,10 @@ void usage(const char *name, const char *badparam, int fps) << " --help, -h" << std::endl << " Display this helper message." << std::endl << std::endl; + std::cout << "\nEXAMPLE " << std::endl + << "- Save aligned color + depth + point cloud in data folder" << std::endl + << " " << name << " -s -a -c -d -p -b -o data" << std::endl + << std::endl; if (badparam) { std::cout << "\nERROR: Bad parameter " << badparam << std::endl; @@ -439,10 +442,8 @@ class vpStorageWorker } } else { -#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) +#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) && defined(VISP_HAVE_PCL_COMMON) pcl::io::savePCDFileBinary(filename_point_cloud, *pointCloud); -#elif defined(VISP_HAVE_PCL) - throw(vpIoException(vpIoException::fatalError, "Cannot save as pcd files without PCL io module")); #endif } } @@ -543,7 +544,6 @@ int main(int argc, const char *argv[]) #endif vpImage I_color(height, width); - vpImage I_gray(height, width); vpImage I_depth(height, width); vpImage I_depth_raw(height, width); vpImage I_infrared(height, width); @@ -553,22 +553,21 @@ int main(int argc, const char *argv[]) #else vpDisplayGDI d1, d2, d3; #endif - d1.init(I_gray, 0, 0, "RealSense color stream"); - d2.init(I_depth, I_gray.getWidth() + 80, 0, "RealSense depth stream"); - d3.init(I_infrared, I_gray.getWidth() + 80, I_gray.getHeight() + 70, "RealSense infrared stream"); + d1.init(I_color, 0, 0, "RealSense color stream"); + d2.init(I_depth, I_color.getWidth() + 80, 0, "RealSense depth stream"); + d3.init(I_infrared, I_color.getWidth() + 80, I_color.getHeight() + 70, "RealSense infrared stream"); while (true) { realsense.acquire((unsigned char *)I_color.bitmap, (unsigned char *)I_depth_raw.bitmap, nullptr, nullptr); - vpImageConvert::convert(I_color, I_gray); vpImageConvert::createDepthHistogram(I_depth_raw, I_depth); - vpDisplay::display(I_gray); + vpDisplay::display(I_color); vpDisplay::display(I_depth); - vpDisplay::displayText(I_gray, 20, 20, "Click when ready.", vpColor::red); - vpDisplay::flush(I_gray); + vpDisplay::displayText(I_color, 20, 20, "Click when ready.", vpColor::red); + vpDisplay::flush(I_color); vpDisplay::flush(I_depth); - if (vpDisplay::getClick(I_gray, false)) { + if (vpDisplay::getClick(I_color, false)) { break; } } @@ -683,23 +682,22 @@ int main(int argc, const char *argv[]) #endif } - vpImageConvert::convert(I_color, I_gray); vpImageConvert::createDepthHistogram(I_depth_raw, I_depth); - vpDisplay::display(I_gray); + vpDisplay::display(I_color); vpDisplay::display(I_depth); vpDisplay::display(I_infrared); if (!click_to_save) { - vpDisplay::displayText(I_gray, 20, 20, "Click to quit.", vpColor::red); + vpDisplay::displayText(I_color, 20, 20, "Click to quit.", vpColor::red); } else { std::stringstream ss; ss << "Images saved: " << nb_saves; - vpDisplay::displayText(I_gray, 20, 20, ss.str(), vpColor::red); + vpDisplay::displayText(I_color, 20, 20, ss.str(), vpColor::red); } - vpDisplay::flush(I_gray); + vpDisplay::flush(I_color); vpDisplay::flush(I_depth); vpDisplay::flush(I_infrared); @@ -713,7 +711,7 @@ int main(int argc, const char *argv[]) } vpMouseButton::vpMouseButtonType button; - if (vpDisplay::getClick(I_gray, button, false)) { + if (vpDisplay::getClick(I_color, button, false)) { if (!click_to_save) { save_queue.cancel(); quit = true; From 7a383db876862ffbd275e3b818a450ecc3f9d3a3 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 25 Apr 2024 10:09:12 +0200 Subject: [PATCH 2/5] Fix command line option helper --- example/device/framegrabber/readRealSenseData.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/example/device/framegrabber/readRealSenseData.cpp b/example/device/framegrabber/readRealSenseData.cpp index 72da852b0f..eca11b6d35 100644 --- a/example/device/framegrabber/readRealSenseData.cpp +++ b/example/device/framegrabber/readRealSenseData.cpp @@ -81,7 +81,7 @@ void usage(const char *name, const char *badparam) << std::endl << "SYNOPSIS " << std::endl << " " << name - << " [--i ]" + << " [-i ]" << " [-c]" << " [-b]" << " [-o]" @@ -89,7 +89,7 @@ void usage(const char *name, const char *badparam) << " [--help,-h]" << std::endl; std::cout << "\nOPTIONS " << std::endl - << " --i " << std::endl + << " -i " << std::endl << " Input folder that contains the data to read." << std::endl << std::endl << " -c" << std::endl @@ -191,8 +191,9 @@ bool readData(int cpt, const std::string &input_directory, vpImage &I_co } // Read color - if (vpIoTools::checkFilename(filename_color)) + if (vpIoTools::checkFilename(filename_color)) { vpImageIo::read(I_color, filename_color); + } // Read raw depth std::ifstream file_depth(filename_depth.c_str(), std::ios::in | std::ios::binary); From 90eba143c32fa3e3ebcd1ee8eb66eb994900d790 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 25 Apr 2024 10:09:52 +0200 Subject: [PATCH 3/5] Fix wrong pcl io protection --- modules/gui/src/pointcloud/vpPclViewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gui/src/pointcloud/vpPclViewer.cpp b/modules/gui/src/pointcloud/vpPclViewer.cpp index a673a2d16c..89794b04f8 100644 --- a/modules/gui/src/pointcloud/vpPclViewer.cpp +++ b/modules/gui/src/pointcloud/vpPclViewer.cpp @@ -35,7 +35,7 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS #include -#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_VISUALIZATION) && defined(VISP_HAVE_THREADS) +#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) && defined(VISP_HAVE_THREADS) // PCL #include From 3b3b0e7e8ea6d530ab4123d86c13ca1d30e1c9c6 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 25 Apr 2024 10:10:24 +0200 Subject: [PATCH 4/5] Fix wrong pcl io protection --- tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp b/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp index bcea5937a6..215b37d28b 100644 --- a/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp +++ b/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp @@ -1,7 +1,7 @@ //! \example ClassUsingPclViewer.cpp #include "ClassUsingPclViewer.h" -#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_VISUALIZATION) +#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) // PCL #include From c9c2553b5ac8318e8ac38b15d757e2b5c488f95a Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 25 Apr 2024 10:13:18 +0200 Subject: [PATCH 5/5] Introduce verbose command line option --- ...tutorial-apriltag-detector-live-rgbd-realsense.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp b/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp index a5cd897381..6fbe8ae7d6 100644 --- a/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp +++ b/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp @@ -27,6 +27,7 @@ int main(int argc, const char **argv) int color_id = -1; unsigned int thickness = 2; bool align_frame = false; + bool opt_verbose = false; #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) bool display_off = true; @@ -66,6 +67,9 @@ int main(int argc, const char **argv) else if (std::string(argv[i]) == "--z_aligned") { align_frame = true; } + else if (std::string(argv[i]) == "--verbose" || std::string(argv[i]) == "-v") { + opt_verbose = true; + } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << "Usage: " << argv[0] << " [--tag_size (default: 0.053)]" @@ -81,7 +85,7 @@ int main(int argc, const char **argv) #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) std::cout << " [--display_off] [--color ] [--thickness ]"; #endif - std::cout << " [--help]" << std::endl; + std::cout << " [--verbose,-v] [--help,-h]" << std::endl; return EXIT_SUCCESS; } } @@ -219,6 +223,11 @@ int main(int argc, const char **argv) std::stringstream ss; ss << "Tag id " << tags_id[i] << " confidence: " << confidence_index; vpDisplay::displayText(I_color2, 35 + i * 15, 20, ss.str(), vpColor::red); + + if (opt_verbose) { + std::cout << "cMo[" << i << "]: \n" << cMo_vec[i] << std::endl; + std::cout << "cMo[" << i << "] using depth: \n" << cMo << std::endl; + } } } //! [Pose from depth map]