From 99ff41eaa274ab5eb7e0097488cc15149d8ad197 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Fri, 5 Apr 2024 17:15:46 +0200 Subject: [PATCH] Realsense tutorial saves also camera parameters --- .../grabber/tutorial-grabber-realsense.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tutorial/grabber/tutorial-grabber-realsense.cpp b/tutorial/grabber/tutorial-grabber-realsense.cpp index f038a51c09..958b866b5f 100644 --- a/tutorial/grabber/tutorial-grabber-realsense.cpp +++ b/tutorial/grabber/tutorial-grabber-realsense.cpp @@ -1,5 +1,6 @@ /*! \example tutorial-grabber-realsense.cpp */ #include +#include #include #include #include @@ -157,6 +158,26 @@ int main(int argc, const char *argv[]) std::cout << "Image size : " << I.getWidth() << " " << I.getHeight() << std::endl; + vpCameraParameters cam = g.getCameraParameters(RS2_STREAM_COLOR, vpCameraParameters::perspectiveProjWithoutDistortion); + vpXmlParserCamera p; + std::string output_folder = vpIoTools::getParent(opt_seqname); + if (!vpIoTools::checkDirectory(output_folder)) { + try { + std::cout << "Create output folder: " << output_folder << std::endl; + vpIoTools::makeDirectory(output_folder); + } + catch (const vpException &e) { + std::cout << e.getStringMessage(); + return EXIT_FAILURE; + } + } + std::string cam_filename = output_folder + "/camera.xml"; + + std::cout << "Save camera intrinsics in: " << cam_filename << std::endl; + if (p.save(cam, cam_filename, "camera")) { + std::cout << "Cannot save camera parameters in " << cam_filename << std::endl; + } + vpDisplay *d = nullptr; if (opt_display) { #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))