40 #include <visp3/core/vpCameraParameters.h>
41 #include <visp3/core/vpException.h>
42 #include <visp3/core/vpMath.h>
43 #include <visp3/core/vpMeterPixelConversion.h>
56 double &rho_p,
double &theta_p)
58 double co = cos(theta_m);
59 double si = sin(theta_m);
66 theta_p = atan2(cam.m_px * si, cam.m_py * co);
67 rho_p = ((cam.m_px * cam.m_py * rho_m) + (cam.m_u0 * cam.m_py * co) + (cam.m_v0 * cam.m_px * si));
98 vpImagePoint ¢er_p,
double &n20_p,
double &n11_p,
double &n02_p)
101 const unsigned int index_0 = 0;
102 const unsigned int index_1 = 1;
103 const unsigned int index_2 = 2;
104 const unsigned int index_3 = 3;
105 const unsigned int index_4 = 4;
106 double xc_m = circle.
p[index_0];
107 double yc_m = circle.
p[index_1];
108 double n20_m = circle.
p[index_2];
109 double n11_m = circle.
p[index_3];
110 double n02_m = circle.
p[index_4];
146 vpImagePoint ¢er_p,
double &n20_p,
double &n11_p,
double &n02_p)
149 const unsigned int index_0 = 0;
150 const unsigned int index_1 = 1;
151 const unsigned int index_2 = 2;
152 const unsigned int index_3 = 3;
153 const unsigned int index_4 = 4;
154 double xc_m = sphere.
p[index_0];
155 double yc_m = sphere.
p[index_1];
156 double n20_m = sphere.
p[index_2];
157 double n11_m = sphere.
p[index_3];
158 double n02_m = sphere.
p[index_4];
187 double n11_m,
double n02_m,
vpImagePoint ¢er_p,
double &n20_p,
188 double &n11_p,
double &n02_p)
197 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_CALIB3D)
209 double &rho_p,
double &theta_p)
211 double co = cos(theta_m);
212 double si = sin(theta_m);
213 double px = cameraMatrix.at<
double>(0, 0);
214 double py = cameraMatrix.at<
double>(1, 1);
215 double u0 = cameraMatrix.at<
double>(0, 2);
216 double v0 = cameraMatrix.at<
double>(1, 2);
219 if (fabs(d) < 1e-6) {
223 theta_p = atan2(px * si, py * co);
224 rho_p = (px * py * rho_m + u0 * py * co + v0 * px * si);
258 double &n20_p,
double &n11_p,
double &n02_p)
260 const unsigned int index_0 = 0;
261 const unsigned int index_1 = 1;
262 const unsigned int index_2 = 2;
263 const unsigned int index_3 = 3;
264 const unsigned int index_4 = 4;
265 const unsigned int index_5 = 5;
266 double px = cameraMatrix.at<
double>(index_0, index_0);
267 double py = cameraMatrix.at<
double>(index_1, index_1);
268 cv::Mat distCoeffs = cv::Mat::zeros(index_5, index_1, CV_64FC1);
270 double xc_m = circle.
p[index_0];
271 double yc_m = circle.
p[index_1];
272 double n20_m = circle.
p[index_2];
273 double n11_m = circle.
p[index_3];
274 double n02_m = circle.
p[index_4];
279 n11_p = n11_m * px * py;
313 double &n20_p,
double &n11_p,
double &n02_p)
315 const unsigned int index_0 = 0;
316 const unsigned int index_1 = 1;
317 const unsigned int index_2 = 2;
318 const unsigned int index_3 = 3;
319 const unsigned int index_4 = 4;
320 const unsigned int index_5 = 5;
321 double px = cameraMatrix.at<
double>(index_0, index_0);
322 double py = cameraMatrix.at<
double>(index_1, index_1);
323 cv::Mat distCoeffs = cv::Mat::zeros(index_5, index_1, CV_64FC1);
325 double xc_m = sphere.
p[index_0];
326 double yc_m = sphere.
p[index_1];
327 double n20_m = sphere.
p[index_2];
328 double n11_m = sphere.
p[index_3];
329 double n02_m = sphere.
p[index_4];
334 n11_p = n11_m * px * py;
357 double n11_m,
double n02_m,
vpImagePoint ¢er_p,
double &n20_p,
358 double &n11_p,
double &n02_p)
360 double px = cameraMatrix.at<
double>(0, 0);
361 double py = cameraMatrix.at<
double>(1, 1);
362 cv::Mat distCoeffs = cv::Mat::zeros(5, 1, CV_64FC1);
367 n11_p = n11_m * px * py;
387 const double &y,
double &u,
double &v)
389 std::vector<cv::Point3d> objectPoints_vec;
390 objectPoints_vec.push_back(cv::Point3d(x, y, 1.0));
391 std::vector<cv::Point2d> imagePoints_vec;
392 cv::projectPoints(objectPoints_vec, cv::Mat::eye(3, 3, CV_64FC1), cv::Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
393 distCoeffs, imagePoints_vec);
394 u = imagePoints_vec[0].x;
395 v = imagePoints_vec[0].y;
415 std::vector<cv::Point3d> objectPoints_vec;
416 objectPoints_vec.push_back(cv::Point3d(x, y, 1.0));
417 std::vector<cv::Point2d> imagePoints_vec;
418 cv::projectPoints(objectPoints_vec, cv::Mat::eye(3, 3, CV_64FC1), cv::Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
419 distCoeffs, imagePoints_vec);
420 iP.
set_u(imagePoints_vec[0].x);
421 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...