Visual Servoing Platform  version 3.4.0
calibrate-camera.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Camera calibration with chessboard or circle calibration grid.
33  *
34  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 #include <iostream>
39 
40 #include <visp3/core/vpConfig.h>
41 
42 #if VISP_HAVE_OPENCV_VERSION >= 0x020300
43 
44 #include <map>
45 
46 #include <opencv2/calib3d/calib3d.hpp>
47 #include <opencv2/core/core.hpp>
48 #include <opencv2/highgui/highgui.hpp>
49 #include <opencv2/imgproc/imgproc.hpp>
50 
51 #include <visp3/vision/vpCalibration.h>
52 
53 #include <visp3/core/vpIoTools.h>
54 #include <visp3/core/vpPoint.h>
55 #include <visp3/core/vpXmlParserCamera.h>
56 #include <visp3/core/vpIoTools.h>
57 #include <visp3/core/vpMeterPixelConversion.h>
58 #include <visp3/core/vpPixelMeterConversion.h>
59 #include <visp3/core/vpImageTools.h>
60 #include <visp3/gui/vpDisplayD3D.h>
61 #include <visp3/gui/vpDisplayGDI.h>
62 #include <visp3/gui/vpDisplayGTK.h>
63 #include <visp3/gui/vpDisplayOpenCV.h>
64 #include <visp3/gui/vpDisplayX.h>
65 #include <visp3/io/vpVideoReader.h>
66 
67 #include "calibration-helper.hpp"
68 
69 using namespace calib_helper;
70 
71 int main(int argc, const char **argv)
72 {
73  try {
74  std::string opt_output_file_name = "camera.xml";
75  Settings s;
76  const std::string opt_inputSettingsFile = argc > 1 ? argv[1] : "default.cfg";
77  std::string opt_init_camera_xml_file;
78  std::string opt_camera_name = "Camera";
79 
80  for (int i = 1; i < argc; i++) {
81  if (std::string(argv[i]) == "--init-from-xml")
82  opt_init_camera_xml_file = std::string(argv[i + 1]);
83  else if (std::string(argv[i]) == "--camera-name")
84  opt_camera_name = std::string(argv[i + 1]);
85  else if (std::string(argv[i]) == "--output")
86  opt_output_file_name = std::string(argv[i + 1]);
87  else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
88  std::cout << "\nUsage: " << argv[0]
89  << " [<configuration file>.cfg] [--init-from-xml <camera-init.xml>]"
90  << " [--camera-name <name>] [--output <file.xml>] [--help] [-h] \n" << std::endl;
91  return EXIT_SUCCESS;
92  }
93  }
94 
95  std::cout << "Settings from config file: " << argv[1] << std::endl;
96  if (!s.read(opt_inputSettingsFile)) {
97  std::cout << "Could not open the configuration file: \"" << opt_inputSettingsFile << "\"" << std::endl;
98  std::cout << std::endl << "Usage: " << argv[0] << " <configuration file>.cfg" << std::endl;
99  return EXIT_FAILURE;
100  }
101 
102  if (!s.goodInput) {
103  std::cout << "Invalid input detected. Application stopping. " << std::endl;
104  return EXIT_FAILURE;
105  }
106 
107  std::cout << "\nSettings from command line options: " << std::endl;
108  if (!opt_init_camera_xml_file.empty()) {
109  std::cout << "Init parameters: " << opt_init_camera_xml_file << std::endl;
110  }
111  std::cout << "Ouput xml file : " << opt_output_file_name << std::endl;
112  std::cout << "Camera name : " << opt_camera_name << std::endl;
113 
114  // Check if output file name exists
115  if (vpIoTools::checkFilename(opt_output_file_name)) {
116  std::cout << "\nOutput file name " << opt_output_file_name << " already exists." << std::endl;
117  std::cout << "Remove this file or change output file name using [--output <file.xml>] command line option." << std::endl;
118  return EXIT_SUCCESS;
119  }
120 
121  // Start the calibration code
123  vpVideoReader reader;
124  reader.setFileName(s.input);
125  try {
126  reader.open(I);
127  }
128  catch(const vpException &e) {
129  std::cout << "Catch an exception: " << e.getStringMessage() << std::endl;
130  std::cout << "Check if input images name \"" << s.input << "\" set in " << opt_inputSettingsFile << " config file is correct..." << std::endl;
131  return EXIT_FAILURE;
132  }
133 
134 #ifdef VISP_HAVE_X11
136 #elif defined VISP_HAVE_GDI
138 #elif defined VISP_HAVE_GTK
140 #elif defined VISP_HAVE_OPENCV
142 #endif
143 
144  vpCameraParameters cam_init;
145  bool init_from_xml = false;
146  if (! opt_init_camera_xml_file.empty()) {
147  if (! vpIoTools::checkFilename(opt_init_camera_xml_file)) {
148  std::cout << "Input camera file \"" << opt_init_camera_xml_file << "\" doesn't exist!" << std::endl;
149  std::cout << "Modify [--init-from-xml <camera-init.xml>] option value" << std::endl;
150  return EXIT_FAILURE;
151  }
152  init_from_xml = true;
153  }
154  if (init_from_xml) {
155  std::cout << "Initialize camera parameters from xml file: " << opt_init_camera_xml_file << std::endl;
156  vpXmlParserCamera parser;
157  if (parser.parse(cam_init, opt_init_camera_xml_file, opt_camera_name, vpCameraParameters::perspectiveProjWithoutDistortion) != vpXmlParserCamera::SEQUENCE_OK) {
158  std::cout << "Unable to find camera with name \"" << opt_camera_name << "\" in file: " << opt_init_camera_xml_file << std::endl;
159  std::cout << "Modify [--camera-name <name>] option value" << std::endl;
160  return EXIT_FAILURE;
161  }
162  } else {
163  std::cout << "Initialize camera parameters with default values " << std::endl;
164  // Initialize camera parameters
165  double px = cam_init.get_px();
166  double py = cam_init.get_py();
167  // Set (u0,v0) in the middle of the image
168  double u0 = I.getWidth() / 2;
169  double v0 = I.getHeight() / 2;
170  cam_init.initPersProjWithoutDistortion(px, py, u0, v0);
171  }
172 
173  std::cout << "Camera parameters used for initialization:\n" << cam_init << std::endl;
174 
175  std::vector<vpPoint> model;
176  std::vector<vpCalibration> calibrator;
177 
178  for (int i = 0; i < s.boardSize.height; i++) {
179  for (int j = 0; j < s.boardSize.width; j++) {
180  model.push_back(vpPoint(j * s.squareSize, i * s.squareSize, 0));
181  }
182  }
183 
184  std::vector<CalibInfo> calib_info;
185  std::multimap< double, vpCameraParameters, std::less<double> > map_cam_sorted; // Sorted by residual
186 
187  map_cam_sorted.insert(std::make_pair(1000, cam_init));
188 
189  do {
190  reader.acquire(I);
191  long frame_index = reader.getFrameIndex();
192  char filename[FILENAME_MAX];
193  sprintf(filename, s.input.c_str(), frame_index);
194  std::string frame_name = vpIoTools::getName(filename);
196  vpDisplay::flush(I);
197 
198  cv::Mat cvI;
199  std::vector<cv::Point2f> pointBuf;
200  vpImageConvert::convert(I, cvI);
201 
202  std::cout << "Process frame: " << frame_name << std::flush;
203  bool found = extractCalibrationPoints(s, cvI, pointBuf);
204 
205  std::cout << ", grid detection status: " << found;
206  if (!found)
207  std::cout << ", image rejected" << std::endl;
208  else
209  std::cout << ", image used as input data" << std::endl;
210 
211  if (found) { // If image processing done with success
212  vpDisplay::setTitle(I, frame_name);
213 
214  std::vector<vpImagePoint> data;
215  for (unsigned int i = 0; i < pointBuf.size(); i++) {
216  vpImagePoint ip(pointBuf[i].y, pointBuf[i].x);
217  data.push_back(ip);
219  }
220 
221  // Calibration on a single mono image
222  std::vector<vpPoint> calib_points;
223  vpCalibration calib;
224  calib.setLambda(0.5);
225  for (unsigned int i = 0; i < model.size(); i++) {
226  calib.addPoint(model[i].get_oX(), model[i].get_oY(), model[i].get_oZ(), data[i]);
227  calib_points.push_back(vpPoint(model[i].get_oX(), model[i].get_oY(), model[i].get_oZ()));
228  calib_points.back().set_x(data[i].get_u());
229  calib_points.back().set_y(data[i].get_v());
230  }
231 
233  bool calib_status = false;
234  std::multimap<double, vpCameraParameters>::const_iterator it_cam;
235  for (it_cam = map_cam_sorted.begin(); it_cam != map_cam_sorted.end(); ++ it_cam) {
236  vpCameraParameters cam = it_cam->second;
237  if (calib.computeCalibration(vpCalibration::CALIB_VIRTUAL_VS, cMo, cam, false) == EXIT_SUCCESS) {
238  calibrator.push_back(calib);
239  // Add calibration info
240  calib_info.push_back(CalibInfo(I, calib_points, data, frame_name));
241  calib_status = true;
242  double residual = calib.getResidual();
243  map_cam_sorted.insert(std::make_pair(residual, cam));
244  break;
245  }
246  }
247  if (! calib_status) {
248  std::cout << "frame: " << frame_name << ", unable to calibrate from single image, image rejected" << std::endl;
249  found = false;
250  }
251  }
252 
253  if (found)
255  "Image processing succeed", vpColor::green);
256  else
258  "Image processing failed", vpColor::green);
259 
260  if (s.tempo > 10.f) {
262  "A click to process the next image", vpColor::green);
263  vpDisplay::flush(I);
265  } else {
266  vpDisplay::flush(I);
267  vpTime::wait(s.tempo * 1000);
268  }
269  } while (!reader.end());
270 
271  // Now we consider the multi image calibration
272  // Calibrate by a non linear method based on virtual visual servoing
273  if (calibrator.empty()) {
274  std::cerr << "Unable to calibrate. Image processing failed !" << std::endl;
275  return 0;
276  }
277 
278  // Display calibration pattern occupancy
279  drawCalibrationOccupancy(I, calib_info, s.boardSize.width);
280  vpDisplay::setTitle(I, "Calibration pattern occupancy");
282  vpDisplay::displayText(I, 15*vpDisplay::getDownScalingFactor(I), 15*vpDisplay::getDownScalingFactor(I), "Calibration pattern occupancy in the image", vpColor::red);
284  vpDisplay::flush(I);
286 
287  std::stringstream ss_additional_info;
288  ss_additional_info << "<date>" << vpTime::getDateTime() << "</date>";
289  ss_additional_info << "<nb_calibration_images>" << calibrator.size() << "</nb_calibration_images>";
290  ss_additional_info << "<calibration_pattern_type>";
291 
292  switch (s.calibrationPattern) {
293  case Settings::CHESSBOARD:
294  ss_additional_info << "Chessboard";
295  break;
296 
297  case Settings::CIRCLES_GRID:
298  ss_additional_info << "Circles grid";
299  break;
300 
301  case Settings::UNDEFINED:
302  default:
303  ss_additional_info << "Undefined";
304  break;
305  }
306  ss_additional_info << "</calibration_pattern_type>";
307  ss_additional_info << "<board_size>" << s.boardSize.width << "x" << s.boardSize.height << "</board_size>";
308  ss_additional_info << "<square_size>" << s.squareSize << "</square_size>";
309 
310  double error;
311  // Initialize with camera parameter that has the lowest residual
312  vpCameraParameters cam = map_cam_sorted.begin()->second;
313  std::cout << "\nCalibration without distortion in progress on " << calibrator.size() << " images..." << std::endl;
314  if (vpCalibration::computeCalibrationMulti(vpCalibration::CALIB_VIRTUAL_VS, calibrator, cam, error, false) == EXIT_SUCCESS) {
315  std::cout << cam << std::endl;
316  vpDisplay::setTitle(I, "Without distorsion results");
317 
318  for (size_t i = 0; i < calibrator.size(); i++) {
319  double reproj_error = sqrt(calibrator[i].getResidual()/calibrator[i].get_npt());
320 
321  const CalibInfo& calib = calib_info[i];
322  std::cout << "Image " << calib.m_frame_name << " reprojection error: " << reproj_error << std::endl;
323  I = calib.m_img;
325 
326  std::ostringstream ss;
327  ss << "Reprojection error: " << reproj_error;
332 
333  for (size_t idx = 0; idx < calib.m_points.size(); idx++) {
335 
336  vpPoint pt = calib.m_points[idx];
337  pt.project(calibrator[i].cMo);
338  vpImagePoint imPt;
339  vpMeterPixelConversion::convertPoint(cam, pt.get_x(), pt.get_y(), imPt);
341  }
342 
344  vpDisplay::flush(I);
346  }
347 
348  std::cout << "\nGlobal reprojection error: " << error << std::endl;
349  ss_additional_info << "<global_reprojection_error><without_distortion>" << error << "</without_distortion>";
350 
351  vpXmlParserCamera xml;
352 
353  if (xml.save(cam, opt_output_file_name.c_str(), opt_camera_name, I.getWidth(), I.getHeight()) ==
355  std::cout << "Camera parameters without distortion successfully saved in \"" << opt_output_file_name << "\""
356  << std::endl;
357  else {
358  std::cout << "Failed to save the camera parameters without distortion in \"" << opt_output_file_name << "\""
359  << std::endl;
360  std::cout << "A file with the same name exists. Remove it to be able "
361  "to save the parameters..."
362  << std::endl;
363  }
364  } else {
365  std::cout << "Calibration without distortion failed." << std::endl;
366  return EXIT_FAILURE;
367  }
368  vpCameraParameters cam_without_dist = cam;
369  std::vector<vpCalibration> calibrator_without_dist = calibrator;
370 
371  std::cout << "\n\nCalibration with distortion in progress on " << calibrator.size() << " images..." << std::endl;
373  EXIT_SUCCESS) {
374  std::cout << cam << std::endl;
375  vpDisplay::setTitle(I, "With distorsion results");
376 
377  for (size_t i = 0; i < calibrator.size(); i++) {
378  double reproj_error = sqrt(calibrator[i].getResidual_dist()/calibrator[i].get_npt());
379 
380  const CalibInfo& calib = calib_info[i];
381  std::cout << "Image " << calib.m_frame_name << " reprojection error: " << reproj_error << std::endl;
382  I = calib.m_img;
384 
385  std::ostringstream ss;
386  ss << "Reprojection error: " << reproj_error;
391 
392  for (size_t idx = 0; idx < calib.m_points.size(); idx++) {
394 
395  vpPoint pt = calib.m_points[idx];
396  pt.project(calibrator[i].cMo_dist);
397  vpImagePoint imPt;
398  vpMeterPixelConversion::convertPoint(cam, pt.get_x(), pt.get_y(), imPt);
400  }
401 
403  vpDisplay::flush(I);
405  }
406 
407  std::cout << "\nGlobal reprojection error: " << error << std::endl;
408  ss_additional_info << "<with_distortion>" << error << "</with_distortion></global_reprojection_error>";
409 
410  vpImage<unsigned char> I_undist = I;
411 #ifdef VISP_HAVE_X11
412  vpDisplayX d_undist(I_undist, I.getWidth()/vpDisplay::getDownScalingFactor(I) + 100, 0, "Undistorted image", vpDisplay::SCALE_AUTO);
413 #elif defined VISP_HAVE_GDI
414  vpDisplayGDI d_undist(I_undist, I.getWidth()/vpDisplay::getDownScalingFactor(I) + 100, 0, "Undistorted image", vpDisplay::SCALE_AUTO);
415 #elif defined VISP_HAVE_GTK
416  vpDisplayGTK d_undist(I_undist, I.getWidth()/vpDisplay::getDownScalingFactor(I) + 100, 0, "Undistorted image", vpDisplay::SCALE_AUTO);
417 #elif defined VISP_HAVE_OPENCV
418  vpDisplayOpenCV d_undist(I_undist, I.getWidth()/vpDisplay::getDownScalingFactor(I) + 100, 0, "Undistorted image", vpDisplay::SCALE_AUTO);
419 #endif
420 
421  vpDisplay::setTitle(I, "Straight lines have to be straight (distorted image)");
422  vpDisplay::setTitle(I_undist, "Straight lines have to be straight (undistorted image)");
423  for (size_t idx = 0; idx < calib_info.size(); idx++) {
424  std::cout << "\nThis tool computes the line fitting error (mean distance error) on image points extracted from the raw distorted image." << std::endl;
425 
426  I = calib_info[idx].m_img;
427  vpImageTools::undistort(I, cam, I_undist);
428 
430  vpDisplay::display(I_undist);
431 
433  vpDisplay::displayText(I, 30*vpDisplay::getDownScalingFactor(I), 15*vpDisplay::getDownScalingFactor(I), "Draw lines from first / last points.", vpColor::red);
434  std::vector<vpImagePoint> grid_points = calib_info[idx].m_imPts;
435  for (int i = 0; i < s.boardSize.height; i++) {
436  std::vector<vpImagePoint> current_line(grid_points.begin() + i*s.boardSize.width,
437  grid_points.begin() + (i+1)*s.boardSize.width);
438 
439  std::vector<vpImagePoint> current_line_undist = undistort(cam, current_line);
440  double a = 0, b = 0, c = 0;
441  double line_fitting_error = vpMath::lineFitting(current_line, a, b, c);
442  double line_fitting_error_undist = vpMath::lineFitting(current_line_undist, a, b, c);
443  std::cout << calib_info[idx].m_frame_name << " line " << i + 1 << " fitting error on distorted points: " << line_fitting_error
444  << " ; on undistorted points: " << line_fitting_error_undist << std::endl;
445 
446  vpImagePoint ip1 = current_line.front();
447  vpImagePoint ip2 = current_line.back();
448  vpDisplay::displayLine(I, ip1, ip2, vpColor::red);
449  }
450 
451  std::cout << "\nThis tool computes the line fitting error (mean distance error) on image points extracted from the undistorted image"
452  << " (vpImageTools::undistort())." << std::endl;
453  cv::Mat cvI;
454  std::vector<cv::Point2f> pointBuf;
455  vpImageConvert::convert(I_undist, cvI);
456 
457  bool found = extractCalibrationPoints(s, cvI, pointBuf);
458  if (found) {
459  std::vector<vpImagePoint> grid_points;
460  for (unsigned int i = 0; i < pointBuf.size(); i++) {
461  vpImagePoint ip(pointBuf[i].y, pointBuf[i].x);
462  grid_points.push_back(ip);
463  }
464 
465  vpDisplay::displayText(I_undist, 15*vpDisplay::getDownScalingFactor(I_undist), 15*vpDisplay::getDownScalingFactor(I_undist), calib_info[idx].m_frame_name + std::string(" undistorted"), vpColor::red);
466  vpDisplay::displayText(I_undist, 30*vpDisplay::getDownScalingFactor(I_undist), 15*vpDisplay::getDownScalingFactor(I_undist), "Draw lines from first / last points.", vpColor::red);
467  for (int i = 0; i < s.boardSize.height; i++) {
468  std::vector<vpImagePoint> current_line(grid_points.begin() + i*s.boardSize.width,
469  grid_points.begin() + (i+1)*s.boardSize.width);
470 
471  double a = 0, b = 0, c = 0;
472  double line_fitting_error = vpMath::lineFitting(current_line, a, b, c);
473  std::cout << calib_info[idx].m_frame_name << " undistorted image, line " << i + 1 << " fitting error: " << line_fitting_error << std::endl;
474 
475  vpImagePoint ip1 = current_line.front();
476  vpImagePoint ip2 = current_line.back();
477  vpDisplay::displayLine(I_undist, ip1, ip2, vpColor::red);
478  }
479  }
480  else {
481  std::string msg("Unable to detect grid on undistorted image");
482  std::cout << msg << std::endl;
483  std::cout << "Check that the grid is not too close to the image edges" << std::endl;
484  vpDisplay::displayText(I_undist, 15*vpDisplay::getDownScalingFactor(I_undist), 15*vpDisplay::getDownScalingFactor(I_undist), calib_info[idx].m_frame_name + std::string(" undistorted"), vpColor::red);
486  }
487 
489  vpDisplay::flush(I);
490  vpDisplay::flush(I_undist);
492  }
493 
494  std::cout << std::endl;
495  vpXmlParserCamera xml;
496 
497  // Camera poses
498  ss_additional_info << "<camera_poses>";
499  for (size_t i = 0; i < calibrator.size(); i++) {
500  vpPoseVector pose(calibrator[i].cMo);
501  ss_additional_info << "<cMo>" << pose.t() << "</cMo>";
502  }
503  for (size_t i = 0; i < calibrator.size(); i++) {
504  vpPoseVector pose(calibrator[i].cMo_dist);
505  ss_additional_info << "<cMo_dist>" << pose.t() << "</cMo_dist>";
506  }
507  ss_additional_info << "</camera_poses>";
508 
509  if (xml.save(cam, opt_output_file_name.c_str(), opt_camera_name, I.getWidth(), I.getHeight(), ss_additional_info.str()) ==
511  std::cout << "Camera parameters without distortion successfully saved in \"" << opt_output_file_name << "\""
512  << std::endl;
513  else {
514  std::cout << "Failed to save the camera parameters without distortion in \"" << opt_output_file_name << "\""
515  << std::endl;
516  std::cout << "A file with the same name exists. Remove it to be able "
517  "to save the parameters..."
518  << std::endl;
519  }
520  std::cout << std::endl;
521  std::cout << "Estimated pose using vpPoseVector format: [tx ty tz tux tuy tuz] with translation in meter and rotation in rad" << std::endl;
522  for (unsigned int i = 0; i < calibrator.size(); i++)
523  std::cout << "Estimated pose on input data extracted from " << calib_info[i].m_frame_name << ": " << vpPoseVector(calibrator[i].cMo_dist).t()
524  << std::endl;
525 
526  } else {
527  std::cout << "Calibration with distortion failed." << std::endl;
528  return EXIT_FAILURE;
529  }
530 
531  return EXIT_SUCCESS;
532  } catch (const vpException &e) {
533  std::cout << "Catch an exception: " << e << std::endl;
534  return EXIT_FAILURE;
535  }
536 }
537 #else
538 int main()
539 {
540  std::cout << "OpenCV 2.3.0 or higher is requested to run the calibration." << std::endl;
541  std::cout << "Tip:" << std::endl;
542  std::cout << "- Install OpenCV, configure again ViSP using cmake and build again this example" << std::endl;
543  return EXIT_SUCCESS;
544 }
545 #endif
VISP_EXPORT int wait(double t0, double t)
Definition: vpTime.cpp:173
long getFrameIndex() const
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static double lineFitting(const std::vector< vpImagePoint > &imPts, double &a, double &b, double &c)
Definition: vpMath.cpp:287
unsigned int getWidth() const
Definition: vpImage.h:246
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
int computeCalibration(vpCalibrationMethodType method, vpHomogeneousMatrix &cMo_est, vpCameraParameters &cam_est, bool verbose=false)
Implementation of an homogeneous matrix and operations on such kind of matrices.
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:128
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:150
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
error that can be emited by ViSP classes.
Definition: vpException.h:71
int addPoint(double X, double Y, double Z, vpImagePoint &ip)
double get_py() const
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.cpp:458
Tools for perspective camera calibration.
Definition: vpCalibration.h:71
XML parser to load and save intrinsic camera parameters.
static const vpColor green
Definition: vpColor.h:220
static void flush(const vpImage< unsigned char > &I)
VISP_EXPORT std::string getDateTime(const std::string &format="%Y/%m/%d %H:%M:%S")
Definition: vpTime.cpp:358
static const vpColor red
Definition: vpColor.h:217
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:81
static void setLambda(const double &lambda)
set the gain for the virtual visual servoing algorithm
void open(vpImage< vpRGBa > &I)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Generic class defining intrinsic camera parameters.
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:134
void acquire(vpImage< vpRGBa > &I)
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.cpp:456
static std::string getName(const std::string &pathname)
Definition: vpIoTools.cpp:1347
double get_px() const
int parse(vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, const vpCameraParameters::vpCameraParametersProjType &projModel, unsigned int image_width=0, unsigned int image_height=0)
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
static void undistort(const vpImage< Type > &I, const vpCameraParameters &cam, vpImage< Type > &newI, unsigned int nThreads=2)
Definition: vpImageTools.h:645
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
unsigned int getDownScalingFactor()
Definition: vpDisplay.h:235
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:151
int save(const vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, unsigned int image_width=0, unsigned int image_height=0, const std::string &additionalInfo="")
void setFileName(const std::string &filename)
static bool checkFilename(const std::string &filename)
Definition: vpIoTools.cpp:640
unsigned int getHeight() const
Definition: vpImage.h:188
const std::string & getStringMessage() const
Send a reference (constant) related the error message (can be empty).
Definition: vpException.cpp:92
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:87
static int computeCalibrationMulti(vpCalibrationMethodType method, std::vector< vpCalibration > &table_cal, vpCameraParameters &cam, double &globalReprojectionError, bool verbose=false)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
vpRowVector t() const
double getResidual(void) const
get the residual in pixels