40 #include <visp3/core/vpCameraParameters.h>
41 #include <visp3/core/vpException.h>
42 #include <visp3/core/vpMath.h>
43 #include <visp3/core/vpMeterPixelConversion.h>
45 #if (VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_CALIB3D)
46 #include <opencv2/calib3d/calib3d.hpp>
48 #if (VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_CALIB) && defined(HAVE_OPENCV_3D)
49 #include <opencv2/calib.hpp>
50 #include <opencv2/3d.hpp>
64 double &rho_p,
double &theta_p)
66 double co = cos(theta_m);
67 double si = sin(theta_m);
74 theta_p = atan2(cam.m_px * si, cam.m_py * co);
75 rho_p = ((cam.m_px * cam.m_py * rho_m) + (cam.m_u0 * cam.m_py * co) + (cam.m_v0 * cam.m_px * si));
106 vpImagePoint ¢er_p,
double &n20_p,
double &n11_p,
double &n02_p)
109 const unsigned int index_0 = 0;
110 const unsigned int index_1 = 1;
111 const unsigned int index_2 = 2;
112 const unsigned int index_3 = 3;
113 const unsigned int index_4 = 4;
114 double xc_m = circle.
p[index_0];
115 double yc_m = circle.
p[index_1];
116 double n20_m = circle.
p[index_2];
117 double n11_m = circle.
p[index_3];
118 double n02_m = circle.
p[index_4];
154 vpImagePoint ¢er_p,
double &n20_p,
double &n11_p,
double &n02_p)
157 const unsigned int index_0 = 0;
158 const unsigned int index_1 = 1;
159 const unsigned int index_2 = 2;
160 const unsigned int index_3 = 3;
161 const unsigned int index_4 = 4;
162 double xc_m = sphere.
p[index_0];
163 double yc_m = sphere.
p[index_1];
164 double n20_m = sphere.
p[index_2];
165 double n11_m = sphere.
p[index_3];
166 double n02_m = sphere.
p[index_4];
195 double n11_m,
double n02_m,
vpImagePoint ¢er_p,
double &n20_p,
196 double &n11_p,
double &n02_p)
205 #if (((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_CALIB3D)) || ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_CALIB) && defined(HAVE_OPENCV_3D)))
217 double &rho_p,
double &theta_p)
219 double co = cos(theta_m);
220 double si = sin(theta_m);
221 double px = cameraMatrix.at<
double>(0, 0);
222 double py = cameraMatrix.at<
double>(1, 1);
223 double u0 = cameraMatrix.at<
double>(0, 2);
224 double v0 = cameraMatrix.at<
double>(1, 2);
227 if (fabs(d) < 1e-6) {
231 theta_p = atan2(px * si, py * co);
232 rho_p = (px * py * rho_m + u0 * py * co + v0 * px * si);
266 double &n20_p,
double &n11_p,
double &n02_p)
268 const unsigned int index_0 = 0;
269 const unsigned int index_1 = 1;
270 const unsigned int index_2 = 2;
271 const unsigned int index_3 = 3;
272 const unsigned int index_4 = 4;
273 const unsigned int index_5 = 5;
274 double px = cameraMatrix.at<
double>(index_0, index_0);
275 double py = cameraMatrix.at<
double>(index_1, index_1);
276 cv::Mat distCoeffs = cv::Mat::zeros(index_5, index_1, CV_64FC1);
278 double xc_m = circle.
p[index_0];
279 double yc_m = circle.
p[index_1];
280 double n20_m = circle.
p[index_2];
281 double n11_m = circle.
p[index_3];
282 double n02_m = circle.
p[index_4];
287 n11_p = n11_m * px * py;
321 double &n20_p,
double &n11_p,
double &n02_p)
323 const unsigned int index_0 = 0;
324 const unsigned int index_1 = 1;
325 const unsigned int index_2 = 2;
326 const unsigned int index_3 = 3;
327 const unsigned int index_4 = 4;
328 const unsigned int index_5 = 5;
329 double px = cameraMatrix.at<
double>(index_0, index_0);
330 double py = cameraMatrix.at<
double>(index_1, index_1);
331 cv::Mat distCoeffs = cv::Mat::zeros(index_5, index_1, CV_64FC1);
333 double xc_m = sphere.
p[index_0];
334 double yc_m = sphere.
p[index_1];
335 double n20_m = sphere.
p[index_2];
336 double n11_m = sphere.
p[index_3];
337 double n02_m = sphere.
p[index_4];
342 n11_p = n11_m * px * py;
365 double n11_m,
double n02_m,
vpImagePoint ¢er_p,
double &n20_p,
366 double &n11_p,
double &n02_p)
368 double px = cameraMatrix.at<
double>(0, 0);
369 double py = cameraMatrix.at<
double>(1, 1);
370 cv::Mat distCoeffs = cv::Mat::zeros(5, 1, CV_64FC1);
375 n11_p = n11_m * px * py;
395 const double &y,
double &u,
double &v)
397 std::vector<cv::Point3d> objectPoints_vec;
398 objectPoints_vec.push_back(cv::Point3d(x, y, 1.0));
399 std::vector<cv::Point2d> imagePoints_vec;
400 cv::projectPoints(objectPoints_vec, cv::Mat::eye(3, 3, CV_64FC1), cv::Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
401 distCoeffs, imagePoints_vec);
402 u = imagePoints_vec[0].x;
403 v = imagePoints_vec[0].y;
423 std::vector<cv::Point3d> objectPoints_vec;
424 objectPoints_vec.push_back(cv::Point3d(x, y, 1.0));
425 std::vector<cv::Point2d> imagePoints_vec;
426 cv::projectPoints(objectPoints_vec, cv::Mat::eye(3, 3, CV_64FC1), cv::Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
427 distCoeffs, imagePoints_vec);
428 iP.
set_u(imagePoints_vec[0].x);
429 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...