39#include <visp3/core/vpCameraParameters.h>
40#include <visp3/core/vpException.h>
41#include <visp3/core/vpMath.h>
42#include <visp3/core/vpMeterPixelConversion.h>
44#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_CALIB3D)
45#include <opencv2/calib3d/calib3d.hpp>
47#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_CALIB) && defined(HAVE_OPENCV_3D)
48#include <opencv2/calib.hpp>
49#include <opencv2/3d.hpp>
65 double &rho_p,
double &theta_p)
67 double co = cos(theta_m);
68 double si = sin(theta_m);
75 theta_p = atan2(cam.m_px * si, cam.m_py * co);
76 rho_p = ((cam.m_px * cam.m_py * rho_m) + (cam.m_u0 * cam.m_py * co) + (cam.m_v0 * cam.m_px * si));
111 vpImagePoint ¢er_p,
double &n20_p,
double &n11_p,
double &n02_p)
114 const unsigned int index_0 = 0;
115 const unsigned int index_1 = 1;
116 const unsigned int index_2 = 2;
117 const unsigned int index_3 = 3;
118 const unsigned int index_4 = 4;
119 double xc_m = circle.
p[index_0];
120 double yc_m = circle.
p[index_1];
121 double n20_m = circle.
p[index_2];
122 double n11_m = circle.
p[index_3];
123 double n02_m = circle.
p[index_4];
128 n11_p = n11_m * cam.get_px() * cam.get_py();
163 vpImagePoint ¢er_p,
double &n20_p,
double &n11_p,
double &n02_p)
166 const unsigned int index_0 = 0;
167 const unsigned int index_1 = 1;
168 const unsigned int index_2 = 2;
169 const unsigned int index_3 = 3;
170 const unsigned int index_4 = 4;
171 double xc_m = sphere.
p[index_0];
172 double yc_m = sphere.
p[index_1];
173 double n20_m = sphere.
p[index_2];
174 double n11_m = sphere.
p[index_3];
175 double n02_m = sphere.
p[index_4];
180 n11_p = n11_m * cam.get_px() * cam.get_py();
217 double n11_m,
double n02_m,
vpImagePoint ¢er_p,
double &n20_p,
218 double &n11_p,
double &n02_p)
223 n11_p = n11_m * cam.get_px() * cam.get_py();
227#if defined(VISP_HAVE_OPENCV) && \
228 (((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_CALIB3D)) || \
229 ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_CALIB) && defined(HAVE_OPENCV_3D)))
242 double &rho_p,
double &theta_p)
244 double co = cos(theta_m);
245 double si = sin(theta_m);
246 double px = cameraMatrix.at<
double>(0, 0);
247 double py = cameraMatrix.at<
double>(1, 1);
248 double u0 = cameraMatrix.at<
double>(0, 2);
249 double v0 = cameraMatrix.at<
double>(1, 2);
252 if (fabs(d) < 1e-6) {
256 theta_p = atan2(px * si, py * co);
257 rho_p = (px * py * rho_m + u0 * py * co + v0 * px * si);
294 double &n20_p,
double &n11_p,
double &n02_p)
296 const unsigned int index_0 = 0;
297 const unsigned int index_1 = 1;
298 const unsigned int index_2 = 2;
299 const unsigned int index_3 = 3;
300 const unsigned int index_4 = 4;
301 const unsigned int index_5 = 5;
302 double px = cameraMatrix.at<
double>(index_0, index_0);
303 double py = cameraMatrix.at<
double>(index_1, index_1);
304 cv::Mat distCoeffs = cv::Mat::zeros(index_5, index_1, CV_64FC1);
306 double xc_m = circle.
p[index_0];
307 double yc_m = circle.
p[index_1];
308 double n20_m = circle.
p[index_2];
309 double n11_m = circle.
p[index_3];
310 double n02_m = circle.
p[index_4];
315 n11_p = n11_m * px * py;
352 double &n20_p,
double &n11_p,
double &n02_p)
354 const unsigned int index_0 = 0;
355 const unsigned int index_1 = 1;
356 const unsigned int index_2 = 2;
357 const unsigned int index_3 = 3;
358 const unsigned int index_4 = 4;
359 const unsigned int index_5 = 5;
360 double px = cameraMatrix.at<
double>(index_0, index_0);
361 double py = cameraMatrix.at<
double>(index_1, index_1);
362 cv::Mat distCoeffs = cv::Mat::zeros(index_5, index_1, CV_64FC1);
364 double xc_m = sphere.
p[index_0];
365 double yc_m = sphere.
p[index_1];
366 double n20_m = sphere.
p[index_2];
367 double n11_m = sphere.
p[index_3];
368 double n02_m = sphere.
p[index_4];
373 n11_p = n11_m * px * py;
408 double n11_m,
double n02_m,
vpImagePoint ¢er_p,
double &n20_p,
409 double &n11_p,
double &n02_p)
411 double px = cameraMatrix.at<
double>(0, 0);
412 double py = cameraMatrix.at<
double>(1, 1);
413 cv::Mat distCoeffs = cv::Mat::zeros(5, 1, CV_64FC1);
418 n11_p = n11_m * px * py;
438 const double &y,
double &u,
double &v)
440 std::vector<cv::Point3d> objectPoints_vec;
441 objectPoints_vec.push_back(cv::Point3d(x, y, 1.0));
442 std::vector<cv::Point2d> imagePoints_vec;
443 cv::projectPoints(objectPoints_vec, cv::Mat::eye(3, 3, CV_64FC1), cv::Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
444 distCoeffs, imagePoints_vec);
445 u = imagePoints_vec[0].x;
446 v = imagePoints_vec[0].y;
466 std::vector<cv::Point3d> objectPoints_vec;
467 objectPoints_vec.push_back(cv::Point3d(x, y, 1.0));
468 std::vector<cv::Point2d> imagePoints_vec;
469 cv::projectPoints(objectPoints_vec, cv::Mat::eye(3, 3, CV_64FC1), cv::Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
470 distCoeffs, imagePoints_vec);
471 iP.
set_u(imagePoints_vec[0].x);
472 iP.
set_v(imagePoints_vec[0].y);
Generic class defining intrinsic camera parameters.
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
error that can be emitted by ViSP classes.
@ divideByZeroError
Division by zero.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static double sqr(double x)
static void convertLine(const vpCameraParameters &cam, const double &rho_m, const double &theta_m, double &rho_p, double &theta_p)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
static void convertEllipse(const vpCameraParameters &cam, const vpSphere &sphere, vpImagePoint ¢er_p, double &n20_p, double &n11_p, double &n02_p)
Class that defines a 3D sphere in the object frame and allows forward projection of a 3D sphere in th...