49 #include <visp3/core/vpCameraParameters.h> 50 #include <visp3/core/vpDebug.h> 51 #include <visp3/core/vpMath.h> 52 #include <visp3/core/vpMeterPixelConversion.h> 53 #include <visp3/core/vpPixelMeterConversion.h> 59 std::cout <<
"* Test operator=()" << std::endl;
64 std::cerr <<
"Issue with vpCameraParameters comparison operator." << std::endl;
70 std::cerr <<
"Issue with vpCameraParameters comparison operator." << std::endl;
74 std::cout <<
"* Test computeFov()" << std::endl;
77 std::cerr <<
"Issue with vpCameraParameters comparison operator." << std::endl;
83 double px, py, u0, v0;
89 double px_dist, py_dist, u0_dist, v0_dist, kud_dist, kdu_dist;
90 px_dist = 1624.824731;
91 py_dist = 1625.263641;
92 u0_dist = 324.0923411;
93 v0_dist = 245.2421388;
94 kud_dist = -0.1741532338;
95 kdu_dist = 0.1771165148;
102 double x1 = 0, y1 = 0;
103 double u2 = 0, v2 = 0;
104 std::cout <<
"* Test point conversion without distorsion" << std::endl;
108 std::cerr <<
"Error in point conversion without distortion:\n" 109 <<
"u1 = " << u1 <<
", u2 = " << u2 << std::endl
110 <<
"v1 = " << v1 <<
", v2 = " << v2 << std::endl;
114 std::cout <<
"* Test point conversion with distorsion" << std::endl;
118 std::cerr <<
"Error in point conversion without distortion:\n" 119 <<
"u1 = " << u1 <<
", u2 = " << u2 << std::endl
120 <<
"v1 = " << v1 <<
", v2 = " << v2 << std::endl;
124 #if VISP_HAVE_OPENCV_VERSION >= 0x020300 126 std::cout <<
"* Compare ViSP and OpenCV point pixel meter conversion without distorsion" << std::endl;
127 cv::Mat cameraMatrix = (cv::Mat_<double>(3,3) << px, 0, u0,
130 cv::Mat distCoeffs = cv::Mat::zeros(5,1,CV_64FC1);
136 std::cerr <<
"Error in point pixel meter conversion: visp result (" << x1 <<
", " << y1 <<
") " 137 <<
"differ from OpenCV result (" << x2 <<
", " << y2 <<
")" << std::endl;
145 std::cerr <<
"Error in point pixel meter conversion: visp result (" << x1 <<
", " << y1 <<
") " 146 <<
"differ from OpenCV result (" << x2 <<
", " << y2 <<
")" << std::endl;
151 std::cout <<
"* Compare ViSP and OpenCV point meter pixel conversion without distorsion" << std::endl;
155 std::cerr <<
"Error in point meter pixel conversion: visp result (" << u1 <<
", " << v1 <<
") " 156 <<
"differ from OpenCV result (" << u2 <<
", " << v2 <<
")" << std::endl;
164 std::cerr <<
"Error in point meter pixel conversion: visp result (" << u1 <<
", " << v1 <<
") " 165 <<
"differ from OpenCV result (" << u2 <<
", " << v2 <<
")" << std::endl;
171 std::cout <<
"* Compare ViSP and OpenCV point pixel meter conversion with distorsion" << std::endl;
172 cv::Mat cameraMatrix = (cv::Mat_<double>(3,3) << px_dist, 0, u0_dist,
175 cv::Mat distCoeffs = cv::Mat::zeros(5,1,CV_64FC1);
176 distCoeffs.at<
double>(0,0) = kdu_dist;
182 std::cerr <<
"Error in point conversion: visp result (" << x1 <<
", " << y1 <<
") " 183 <<
"differ from OpenCV result (" << x2 <<
", " << y2 <<
")" << std::endl;
187 std::cout <<
"* Compare ViSP and OpenCV point meter pixel conversion with distorsion" << std::endl;
188 distCoeffs.at<
double>(0,0) = kud_dist;
192 std::cerr <<
"Error in point meter pixel conversion: visp result (" << u1 <<
", " << v1 <<
") " 193 <<
"differ from OpenCV result (" << u2 <<
", " << v2 <<
")" << std::endl;
199 std::cout <<
"* Compare ViSP and OpenCV line pixel meter conversion without distorsion" << std::endl;
200 cv::Mat cameraMatrix = (cv::Mat_<double>(3,3) << px, 0, u0,
204 double rho_m1, theta_m1, rho_m2, theta_m2;
209 std::cerr <<
"Error in line pixel meter conversion: visp result (" << rho_m1 <<
", " << theta_m1 <<
") " 210 <<
"differ from OpenCV result (" << rho_m2 <<
", " << theta_m1 <<
")" << std::endl;
214 std::cout <<
"* Compare ViSP and OpenCV line meter pixel conversion without distorsion" << std::endl;
215 double rho_p1, theta_p1, rho_p2, theta_p2;
219 std::cerr <<
"Error in line meter pixel conversion: visp result (" << rho_p1 <<
", " << theta_p1 <<
") " 220 <<
"differ from OpenCV result (" << rho_p2 <<
", " << theta_p1 <<
")" << std::endl;
226 std::cout <<
"* Compare ViSP and OpenCV moments pixel meter conversion without distorsion" << std::endl;
227 cv::Mat cameraMatrix = (cv::Mat_<double>(3,3) << px, 0, u0,
230 unsigned int order = 3;
231 double m00 = 2442, m10 = 414992, m01 = 470311, m11 = 7.99558e+07, m02 = 9.09603e+07, m20 = 7.11158e+07;
234 vpMatrix m1(order, order), m2(order, order);
245 for (
unsigned int i = 0; i < m1.getRows(); i ++) {
246 for (
unsigned int j = 0; j < m1.getCols(); j ++) {
248 std::cerr <<
"Error in moments pixel meter conversion: visp result for ["<< i <<
"]["<< j <<
"] (" << m1[i][j] <<
") " 249 <<
"differ from OpenCV result (" << m2[i][j] <<
")" << std::endl;
257 std::cout <<
"* Compare ViSP and OpenCV ellipse from circle meter pixel conversion without distorsion" << std::endl;
258 cv::Mat cameraMatrix = (cv::Mat_<double>(3,3) << px, 0, u0,
267 double mu20_p1, mu11_p1, mu02_p1, mu20_p2, mu11_p2, mu02_p2;
273 std::cerr <<
"Error in ellipse from circle meter pixel conversion: visp result (" << mu20_p1 <<
", " << mu11_p1 <<
", " << mu02_p1 <<
") " 274 <<
"differ from OpenCV result (" << mu20_p2 <<
", " << mu11_p2 <<
", " << mu02_p2 <<
")" << std::endl;
278 std::cerr <<
"Error in ellipse from circle meter pixel conversion: visp result (" << center_p1 <<
") " 279 <<
"differ from OpenCV result (" << center_p2 <<
")" << std::endl;
283 std::cout <<
"* Compare ViSP and OpenCV ellipse from sphere meter pixel conversion without distorsion" << std::endl;
292 std::cerr <<
"Error in ellipse from sphere meter pixel conversion: visp result (" << mu20_p1 <<
", " << mu11_p1 <<
", " << mu02_p1 <<
") " 293 <<
"differ from OpenCV result (" << mu20_p2 <<
", " << mu11_p2 <<
", " << mu02_p2 <<
")" << std::endl;
297 std::cerr <<
"Error in ellipse from sphere meter pixel conversion: visp result (" << center_p1 <<
") " 298 <<
"differ from OpenCV result (" << center_p2 <<
")" << std::endl;
304 std::cout <<
"Test succesful" << std::endl;
307 std::cout <<
"Catch an exception: " << e << std::endl;
Implementation of a matrix and operations on matrices.
static void convertEllipse(const vpCameraParameters &cam, const vpSphere &sphere, vpImagePoint ¢er, double &mu20_p, double &mu11_p, double &mu02_p)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP)
perspective projection of the circle
Implementation of an homogeneous matrix and operations on such kind of matrices.
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
static bool equal(double x, double y, double s=0.001)
error that can be emited by ViSP classes.
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Class that defines what is a sphere.
void setWorldCoordinates(const vpColVector &oP)
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
Generic class defining intrinsic camera parameters.
static double rad(double deg)
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
static void convertLine(const vpCameraParameters &cam, const double &rho_m, const double &theta_m, double &rho_p, double &theta_p)
static void convertMoment(const vpCameraParameters &cam, unsigned int order, const vpMatrix &moment_pixel, vpMatrix &moment_meter)
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)
Class that defines what is a circle.
static double distance(const vpImagePoint &iP1, const vpImagePoint &iP2)
void setWorldCoordinates(const vpColVector &oP)
void computeFov(const unsigned int &w, const unsigned int &h)