Skip to content

Commit

Permalink
Realsense tutorial saves also camera parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Apr 5, 2024
1 parent e34367a commit 99ff41e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tutorial/grabber/tutorial-grabber-realsense.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*! \example tutorial-grabber-realsense.cpp */
#include <visp3/core/vpImage.h>
#include <visp3/core/vpXmlParserCamera.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 99ff41e

Please sign in to comment.