Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpCalibration.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Camera calibration.
32 */
33
38#ifndef VP_CALIBRATION_H
39#define VP_CALIBRATION_H
40
41#include <list>
42#include <vector>
43#include <visp3/core/vpCameraParameters.h>
44#include <visp3/core/vpDisplay.h>
45#include <visp3/core/vpExponentialMap.h>
46#include <visp3/core/vpHomogeneousMatrix.h>
47#include <visp3/core/vpImage.h>
48#include <visp3/core/vpImagePoint.h>
49#include <visp3/core/vpMath.h>
50#include <visp3/core/vpMatrix.h>
51#include <visp3/vision/vpCalibrationException.h>
52
63class VISP_EXPORT vpCalibration
64{
65public:
85
103
116
121
126
131
135 virtual ~vpCalibration();
136
144 int addPoint(double X, double Y, double Z, vpImagePoint &ip);
145
151 vpCalibration &operator=(const vpCalibration &twinCalibration);
152
156 int clearPoint();
157
170 bool verbose = false);
171
186 static int computeCalibrationMulti(vpCalibrationMethodType method, std::vector<vpCalibration> &table_cal,
187 vpCameraParameters &cam_est, double &globalReprojectionError, bool verbose = false);
188
197 void computeStdDeviation(double &deviation, double &deviation_dist);
198
208 double computeStdDeviation(const vpHomogeneousMatrix &cMo_est, const vpCameraParameters &camera);
209
218 double computeStdDeviation_dist(const vpHomogeneousMatrix &cMo_est, const vpCameraParameters &camera);
219
230 int displayData(vpImage<unsigned char> &I, vpColor color = vpColor::red, unsigned int thickness = 1,
231 int subsampling_factor = 1);
232
243 int displayGrid(vpImage<unsigned char> &I, vpColor color = vpColor::yellow, unsigned int thickness = 1,
244 int subsampling_factor = 1);
245
247 static double getLambda() { return m_gain; }
248
252 double getResidual(void) const { return m_residual; }
253
257 double getResidual_dist(void) const { return m_residual_dist; }
258
262 unsigned int get_npt() const { return m_npt; }
263
267 int init();
268
275 int readData(const std::string &filename);
276
292 static int readGrid(const std::string &filename, unsigned int &n, std::list<double> &oX, std::list<double> &oY,
293 std::list<double> &oZ, bool verbose = false);
294
298 static void setLambda(const double &lambda) { m_gain = lambda; }
299
306 void setAspectRatio(double aspect_ratio);
307
315 int writeData(const std::string &filename);
316
317private:
318 void computePose(const vpCameraParameters &cam, vpHomogeneousMatrix &cMo);
319 void calibLagrange(vpCameraParameters &cam, vpHomogeneousMatrix &cMo);
320
322 void calibVVS(vpCameraParameters &cam, vpHomogeneousMatrix &cMo, bool verbose = false);
323
324 static void calibVVSMulti(unsigned int nbPose, vpCalibration table_cal[], vpCameraParameters &cam,
325 bool verbose = false, double aspect_ratio = -1);
326 static void calibVVSMulti(std::vector<vpCalibration> &table_cal, vpCameraParameters &cam,
327 double &globalReprojectionError, bool verbose = false, double aspect_ratio = -1);
328 void calibVVSWithDistortion(vpCameraParameters &cam, vpHomogeneousMatrix &cMo, bool verbose = false);
329 static void calibVVSWithDistortionMulti(unsigned int nbPose, vpCalibration table_cal[], vpCameraParameters &cam,
330 bool verbose = false, double aspect_ratio = -1);
331 static void calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal, vpCameraParameters &cam,
332 double &globalReprojectionError, bool verbose = false,
333 double aspect_ratio = -1);
334
335 unsigned int m_npt;
336 std::list<double> m_LoX, m_LoY, m_LoZ;
337 std::list<vpImagePoint> m_Lip;
338
339 double m_residual;
340 double m_residual_dist;
342
343 static double m_threshold;
344 static unsigned int m_nbIterMax;
345 static double m_gain;
346};
347END_VISP_NAMESPACE
348#endif
Tools for perspective camera intrinsic parameters calibration.
void computeStdDeviation(double &deviation, double &deviation_dist)
static void setLambda(const double &lambda)
int displayData(vpImage< unsigned char > &I, vpColor color=vpColor::red, unsigned int thickness=1, int subsampling_factor=1)
static double getLambda()
Get the gain of the virtual visual servoing algorithm.
unsigned int get_npt() const
double m_aspect_ratio
int computeCalibration(vpCalibrationMethodType method, vpHomogeneousMatrix &cMo_est, vpCameraParameters &cam_est, bool verbose=false)
double getResidual(void) const
int addPoint(double X, double Y, double Z, vpImagePoint &ip)
vpHomogeneousMatrix eMc_dist
vpHomogeneousMatrix rMe
vpCalibration & operator=(const vpCalibration &twinCalibration)
vpHomogeneousMatrix cMo
double computeStdDeviation_dist(const vpHomogeneousMatrix &cMo_est, const vpCameraParameters &camera)
static int computeCalibrationMulti(vpCalibrationMethodType method, std::vector< vpCalibration > &table_cal, vpCameraParameters &cam_est, double &globalReprojectionError, bool verbose=false)
vpCameraParameters cam_dist
double getResidual_dist(void) const
vpHomogeneousMatrix eMc
vpHomogeneousMatrix cMo_dist
int displayGrid(vpImage< unsigned char > &I, vpColor color=vpColor::yellow, unsigned int thickness=1, int subsampling_factor=1)
@ CALIB_LAGRANGE_VIRTUAL_VS_DIST
vpCameraParameters cam
Generic class defining intrinsic camera parameters.
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
static const vpColor red
Definition vpColor.h:198
static const vpColor yellow
Definition vpColor.h:206
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
Definition vpImage.h:131