44 #include <visp3/core/vpCameraParameters.h>
45 #include <visp3/core/vpDebug.h>
46 #include <visp3/core/vpException.h>
47 #include <visp3/core/vpMath.h>
48 #include <visp3/core/vpPixelMeterConversion.h>
61 double n11_p,
double n02_p,
double &xc_m,
double &yc_m,
double &n20_m,
62 double &n11_m,
double &n02_m)
68 n20_m = n20_p / (px * px);
69 n11_m = n11_p / (px * py);
70 n02_m = n02_p / (py * py);
83 double &rho_m,
double &theta_m)
85 double co = cos(theta_p);
86 double si = sin(theta_p);
93 theta_m = atan2(si * cam.py, co * cam.px);
94 rho_m = (rho_p - cam.u0 * co - cam.v0 * si) / sqrt(d);
141 for (
unsigned int k = 0; k < order; k++)
143 for (
unsigned int p = 0; p < order; p++)
144 for (
unsigned int q = 0; q < order; q++)
148 for (
unsigned int r = 0; r <= p; r++)
149 for (
unsigned int t = 0; t <= q; t++)
152 pow(xc, (
int)(p - r)) * pow(yc, (
int)(q - t)) * moment_pixel[r][t];
157 for (
unsigned int k = 0; k < order; k++)
158 for (
unsigned int p = 0; p < order; p++)
159 for (
unsigned int q = 0; q < order; q++)
161 m[p][q] *= pow(cam.inv_px, (
int)(1 + p)) * pow(cam.inv_py, (
int)(1 + q));
164 for (
unsigned int k = 0; k < order; k++)
165 for (
unsigned int p = 0; p < order; p++)
166 for (
unsigned int q = 0; q < order; q++)
168 moment_meter[p][q] = m[p][q];
172 #if VISP_HAVE_OPENCV_VERSION >= 0x020300
186 const vpImagePoint ¢er_p,
double n20_p,
double n11_p,
double n02_p,
187 double &xc_m,
double &yc_m,
double &n20_m,
double &n11_m,
double &n02_m)
190 double px = cameraMatrix.at<
double>(0, 0);
191 double py = cameraMatrix.at<
double>(1, 1);
193 n20_m = n20_p / (px * px);
194 n11_m = n11_p / (px * py);
195 n02_m = n02_p / (py * py);
208 double &rho_m,
double &theta_m)
210 double co = cos(theta_p);
211 double si = sin(theta_p);
212 double px = cameraMatrix.at<
double>(0, 0);
213 double py = cameraMatrix.at<
double>(1, 1);
214 double u0 = cameraMatrix.at<
double>(0, 2);
215 double v0 = cameraMatrix.at<
double>(1, 2);
219 if (fabs(d) < 1e-6) {
223 theta_m = atan2(si * py, co * px);
224 rho_m = (rho_p - u0 * co - v0 * si) / sqrt(d);
239 double inv_px = 1. / cameraMatrix.at<
double>(0, 0);
240 double inv_py = 1. / cameraMatrix.at<
double>(1, 1);
241 double u0 = cameraMatrix.at<
double>(0, 2);
242 double v0 = cameraMatrix.at<
double>(1, 2);
248 for (
unsigned int k = 0; k < order; k++)
250 for (
unsigned int p = 0; p < order; p++)
251 for (
unsigned int q = 0; q < order; q++)
255 for (
unsigned int r = 0; r <= p; r++)
256 for (
unsigned int t = 0; t <= q; t++)
259 pow(xc,
static_cast<int>(p - r)) * pow(yc,
static_cast<int>(q - t)) * moment_pixel[r][t];
264 for (
unsigned int k = 0; k < order; k++)
265 for (
unsigned int p = 0; p < order; p++)
266 for (
unsigned int q = 0; q < order; q++)
268 m[p][q] *= pow(inv_px,
static_cast<int>(1 + p)) * pow(inv_py,
static_cast<int>(1 + q));
271 for (
unsigned int k = 0; k < order; k++)
272 for (
unsigned int p = 0; p < order; p++)
273 for (
unsigned int q = 0; q < order; q++)
275 moment_meter[p][q] = m[p][q];
294 const double &v,
double &x,
double &y)
296 std::vector<cv::Point2d> imagePoints_vec;
297 imagePoints_vec.push_back(cv::Point2d(u, v));
298 std::vector<cv::Point2d> objectPoints_vec;
299 cv::undistortPoints(imagePoints_vec, objectPoints_vec, cameraMatrix, distCoeffs);
300 x = objectPoints_vec[0].x;
301 y = objectPoints_vec[0].y;
320 std::vector<cv::Point2d> imagePoints_vec;
321 imagePoints_vec.push_back(cv::Point2d(iP.
get_u(), iP.
get_v()));
322 std::vector<cv::Point2d> objectPoints_vec;
323 cv::undistortPoints(imagePoints_vec, objectPoints_vec, cameraMatrix, distCoeffs);
324 x = objectPoints_vec[0].x;
325 y = objectPoints_vec[0].y;
Generic class defining intrinsic camera parameters.
error that can be emited 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 long double comb(unsigned int n, unsigned int p)
Implementation of a matrix and operations on matrices.
static void convertEllipse(const vpCameraParameters &cam, const vpImagePoint ¢er_p, double n20_p, double n11_p, double n02_p, double &xc_m, double &yc_m, double &n20_m, double &n11_m, double &n02_m)
static void convertMoment(const vpCameraParameters &cam, unsigned int order, const vpMatrix &moment_pixel, vpMatrix &moment_meter)
static void convertLine(const vpCameraParameters &cam, const double &rho_p, const double &theta_p, double &rho_m, double &theta_m)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)