40 #include <visp3/core/vpCameraParameters.h>
41 #include <visp3/core/vpDebug.h>
42 #include <visp3/core/vpException.h>
43 #include <visp3/core/vpMath.h>
44 #include <visp3/core/vpPixelMeterConversion.h>
57 double n11_p,
double n02_p,
double &xc_m,
double &yc_m,
double &n20_m,
58 double &n11_m,
double &n02_m)
64 n20_m = n20_p / (px * px);
65 n11_m = n11_p / (px * py);
66 n02_m = n02_p / (py * py);
79 double &rho_m,
double &theta_m)
81 double co = cos(theta_p);
82 double si = sin(theta_p);
89 theta_m = atan2(si * cam.m_py, co * cam.m_px);
90 rho_m = (rho_p - (cam.m_u0 * co) - (cam.m_v0 * si)) / sqrt(d);
134 double yc = -cam.m_v0;
135 double xc = -cam.m_u0;
137 for (
unsigned int k = 0; k < order; ++k) {
138 for (
unsigned int p = 0; p < order; ++p) {
139 for (
unsigned int q = 0; q < order; ++q) {
142 for (
unsigned int r = 0; r <= p; ++r) {
143 for (
unsigned int t = 0; t <= q; ++t) {
145 pow(xc,
static_cast<int>(p - r)) * pow(yc,
static_cast<int>(q - t)) * moment_pixel[r][t];
153 for (
unsigned int k = 0; k < order; ++k) {
154 for (
unsigned int p = 0; p < order; ++p) {
155 for (
unsigned int q = 0; q < order; ++q) {
157 m[p][q] *= pow(cam.m_inv_px,
static_cast<int>(1 + p)) * pow(cam.m_inv_py,
static_cast<int>(1 + q));
163 for (
unsigned int k = 0; k < order; ++k) {
164 for (
unsigned int p = 0; p < order; ++p) {
165 for (
unsigned int q = 0; q < order; ++q) {
167 moment_meter[p][q] = m[p][q];
174 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_CALIB3D) && defined(HAVE_OPENCV_IMGPROC)
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 double &rho_m,
double &theta_m)
213 double co = cos(theta_p);
214 double si = sin(theta_p);
215 double px = cameraMatrix.at<
double>(0, 0);
216 double py = cameraMatrix.at<
double>(1, 1);
217 double u0 = cameraMatrix.at<
double>(0, 2);
218 double v0 = cameraMatrix.at<
double>(1, 2);
222 if (fabs(d) < 1e-6) {
226 theta_m = atan2(si * py, co * px);
227 rho_m = (rho_p - u0 * co - v0 * si) / sqrt(d);
243 double inv_px = 1. / cameraMatrix.at<
double>(0, 0);
244 double inv_py = 1. / cameraMatrix.at<
double>(1, 1);
245 double u0 = cameraMatrix.at<
double>(0, 2);
246 double v0 = cameraMatrix.at<
double>(1, 2);
252 for (
unsigned int k = 0; k < order; ++k) {
253 for (
unsigned int p = 0; p < order; ++p) {
254 for (
unsigned int q = 0; q < order; ++q) {
257 for (
unsigned int r = 0; r <= p; ++r) {
258 for (
unsigned int t = 0; t <= q; ++t) {
260 pow(xc,
static_cast<int>(p - r)) * pow(yc,
static_cast<int>(q - t)) * moment_pixel[r][t];
268 for (
unsigned int k = 0; k < order; ++k) {
269 for (
unsigned int p = 0; p < order; ++p) {
270 for (
unsigned int q = 0; q < order; ++q) {
272 m[p][q] *= pow(inv_px,
static_cast<int>(1 + p)) * pow(inv_py,
static_cast<int>(1 + q));
278 for (
unsigned int k = 0; k < order; ++k) {
279 for (
unsigned int p = 0; p < order; ++p) {
280 for (
unsigned int q = 0; q < order; ++q) {
282 moment_meter[p][q] = m[p][q];
304 const double &v,
double &x,
double &y)
306 std::vector<cv::Point2d> imagePoints_vec;
307 imagePoints_vec.push_back(cv::Point2d(u, v));
308 std::vector<cv::Point2d> objectPoints_vec;
309 cv::undistortPoints(imagePoints_vec, objectPoints_vec, cameraMatrix, distCoeffs);
310 x = objectPoints_vec[0].x;
311 y = objectPoints_vec[0].y;
330 std::vector<cv::Point2d> imagePoints_vec;
331 imagePoints_vec.push_back(cv::Point2d(iP.
get_u(), iP.
get_v()));
332 std::vector<cv::Point2d> objectPoints_vec;
333 cv::undistortPoints(imagePoints_vec, objectPoints_vec, cameraMatrix, distCoeffs);
334 x = objectPoints_vec[0].x;
335 y = objectPoints_vec[0].y;
Generic class defining intrinsic camera parameters.
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 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)