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 const vpImagePoint ¢er_p,
double n20_p,
double n11_p,
double n02_p,
62 double &xc_m,
double &yc_m,
double &n20_m,
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 const double &rho_p,
const double &theta_p,
84 double &rho_m,
double &theta_m)
86 double co = cos(theta_p);
87 double si = sin(theta_p);
94 theta_m = atan2(si * cam.py, co * cam.px);
95 rho_m = (rho_p - cam.u0 * co - cam.v0 * si) / sqrt(d);
136 unsigned int order,
const vpMatrix &moment_pixel,
143 for (
unsigned int k = 0; k < order; k++)
145 for (
unsigned int p = 0; p < order; p++)
146 for (
unsigned int q = 0; q < order; q++)
150 for (
unsigned int r = 0; r <= p; r++)
151 for (
unsigned int t = 0; t <= q; t++)
154 pow(xc, (
int)(p - r)) * pow(yc, (
int)(q - t)) * moment_pixel[r][t];
159 for (
unsigned int k = 0; k < order; k++)
160 for (
unsigned int p = 0; p < order; p++)
161 for (
unsigned int q = 0; q < order; q++)
163 m[p][q] *= pow(cam.inv_px, (
int)(1 + p)) * pow(cam.inv_py, (
int)(1 + q));
166 for (
unsigned int k = 0; k < order; k++)
167 for (
unsigned int p = 0; p < order; p++)
168 for (
unsigned int q = 0; q < order; q++)
170 moment_meter[p][q] = m[p][q];
174 #if VISP_HAVE_OPENCV_VERSION >= 0x020300 189 const vpImagePoint ¢er_p,
double n20_p,
double n11_p,
double n02_p,
190 double &xc_m,
double &yc_m,
double &n20_m,
double &n11_m,
double &n02_m)
193 double px = cameraMatrix.at<
double>(0,0);
194 double py = cameraMatrix.at<
double>(1,1);
196 n20_m = n20_p / (px * px);
197 n11_m = n11_p / (px * py);
198 n02_m = n02_p / (py * py);
211 const double &rho_p,
const double &theta_p,
212 double &rho_m,
double &theta_m)
214 double co = cos(theta_p);
215 double si = sin(theta_p);
216 double px = cameraMatrix.at<
double>(0,0);
217 double py = cameraMatrix.at<
double>(1,1);
218 double u0 = cameraMatrix.at<
double>(0,2);
219 double v0 = cameraMatrix.at<
double>(1,2);
223 if (fabs(d) < 1e-6) {
227 theta_m = atan2(si * py, co * px);
228 rho_m = (rho_p - u0 * co - v0 * si) / sqrt(d);
242 unsigned int order,
const vpMatrix &moment_pixel,
245 double inv_px = 1. / cameraMatrix.at<
double>(0,0);
246 double inv_py = 1. / cameraMatrix.at<
double>(1,1);
247 double u0 = cameraMatrix.at<
double>(0,2);
248 double v0 = cameraMatrix.at<
double>(1,2);
254 for (
unsigned int k = 0; k < order; k++)
256 for (
unsigned int p = 0; p < order; p++)
257 for (
unsigned int q = 0; q < order; q++)
261 for (
unsigned int r = 0; r <= p; r++)
262 for (
unsigned int t = 0; t <= q; t++)
265 pow(xc, static_cast<int>(p - r)) * pow(yc, static_cast<int>(q - t)) * moment_pixel[r][t];
270 for (
unsigned int k = 0; k < order; k++)
271 for (
unsigned int p = 0; p < order; p++)
272 for (
unsigned int q = 0; q < order; q++)
274 m[p][q] *= pow(inv_px, static_cast<int>(1 + p)) * pow(inv_py, static_cast<int>(1 + q));
277 for (
unsigned int k = 0; k < order; k++)
278 for (
unsigned int p = 0; p < order; p++)
279 for (
unsigned int q = 0; q < order; q++)
281 moment_meter[p][q] = m[p][q];
300 const double &u,
const double &v,
double &x,
double &y)
302 std::vector<cv::Point2d> imagePoints_vec;
303 imagePoints_vec.push_back(cv::Point2d(u, v));
304 std::vector<cv::Point2d> objectPoints_vec;
305 cv::undistortPoints(imagePoints_vec, objectPoints_vec, cameraMatrix, distCoeffs);
306 x = objectPoints_vec[0].x;
307 y = objectPoints_vec[0].y;
326 std::vector<cv::Point2d> imagePoints_vec;
327 imagePoints_vec.push_back(cv::Point2d(iP.
get_u(), iP.
get_v()));
328 std::vector<cv::Point2d> objectPoints_vec;
329 cv::undistortPoints(imagePoints_vec, objectPoints_vec, cameraMatrix, distCoeffs);
330 x = objectPoints_vec[0].x;
331 y = objectPoints_vec[0].y;
Implementation of a matrix and operations on matrices.
error that can be emited by ViSP classes.
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
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 double sqr(double x)
Generic class defining intrinsic camera parameters.
static void convertMoment(const vpCameraParameters &cam, unsigned int order, const vpMatrix &moment_pixel, vpMatrix &moment_meter)
static long double comb(unsigned int n, unsigned int p)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void convertLine(const vpCameraParameters &cam, const double &rho_p, const double &theta_p, double &rho_m, double &theta_m)