Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CERES_COSTS_UTILS_TEST_HPP_
00020 #define CERES_COSTS_UTILS_TEST_HPP_
00021
00022 #include "ceres/ceres.h"
00023 #include "ceres/rotation.h"
00024 #include <industrial_extrinsic_cal/basic_types.h>
00025
00026 namespace industrial_extrinsic_cal
00027 {
00028
00029
00030
00040 void printQTasH(double qx, double qy, double qz, double qw, double tx, double ty, double tz);
00041
00050 void printAATasH(double ax, double ay, double az, double tx, double ty, double tz);
00051
00060 void printAATasHI(double ax, double ay, double az, double tx, double ty, double tz);
00061
00067 void printAAasEuler(double ax, double ay, double az);
00068
00073 void printCameraParameters(CameraParameters C, std::string words);
00074
00079 Observation projectPointWithDistortion(CameraParameters camera_parameters, Point3d point);
00080 Observation projectPointNoDistortion(CameraParameters camera_params, Point3d point_to_project);
00081
00082 Observation projectPointWithDistortion(CameraParameters C, Point3d P)
00083 {
00084 double p[3];
00085 double pt[3];
00086 pt[0] = P.x;
00087 pt[1] = P.y;
00088 pt[2] = P.z;
00089
00090
00091
00092 double aa[3];
00093 aa[0]=C.pb_extrinsics[0];
00094 aa[1]=C.pb_extrinsics[1];
00095 aa[2]=C.pb_extrinsics[2];
00096 ceres::AngleAxisRotatePoint(aa, pt, p);
00097
00098
00099 double xp1 = p[0] + C.pb_extrinsics[3];
00100 double yp1 = p[1] + C.pb_extrinsics[4];
00101 double zp1 = p[2] + C.pb_extrinsics[5];
00102
00103
00104
00105
00106 double xp = xp1 / zp1;
00107 double yp = yp1 / zp1;
00108
00109
00110 double r2 = xp * xp + yp * yp;
00111 double r4 = r2 * r2;
00112 double r6 = r2 * r4;
00113
00114 double xp2 = xp * xp;
00115 double yp2 = yp * yp;
00116
00117
00118 double xpp = xp + C.distortion_k1 * r2 * xp + C.distortion_k2 * r4 * xp +
00119 C.distortion_k3 * r6 * xp + C.distortion_p2 * (r2 + 2 * xp2) + 2 * C.distortion_p1 * xp * yp;
00120 double ypp = yp + C.distortion_k1 * r2 * yp + C.distortion_k2 * r4 * yp +
00121 C.distortion_k3 * r6 * yp + C.distortion_p1 * (r2 + 2 * yp2) + 2 * C.distortion_p2 * xp * yp;
00122
00123
00124 Observation O;
00125 O.point_id = 0;
00126 O.image_loc_x = C.focal_length_x * xpp + C.center_x;
00127 O.image_loc_y = C.focal_length_y * ypp + C.center_y;
00128 return (O);
00129 }
00130
00131 Observation projectPointNoDistortion(CameraParameters C, Point3d P)
00132 {
00133 double p[3];
00134 double point[3];
00135 double aa[3];
00136 double tx = C.position[0];
00137 double ty = C.position[1];
00138 double tz = C.position[2];
00139 double fx = C.focal_length_x;
00140 double fy = C.focal_length_y;
00141 double cx = C.center_x;
00142 double cy = C.center_y;
00143
00144 aa[0] = C.angle_axis[0];
00145 aa[1] = C.angle_axis[1];
00146 aa[2] = C.angle_axis[2];
00147 point[0] = P.x;
00148 point[1] = P.y;
00149 point[2] = P.z;
00150
00152 ceres::AngleAxisRotatePoint(aa, point, p);
00153
00154
00155 double xp1 = p[0] + tx;
00156 double yp1 = p[1] + ty;
00157 double zp1 = p[2] + tz;
00158
00159
00160 double xp = xp1 / zp1;
00161 double yp = yp1 / zp1;
00162
00163
00164 Observation O;
00165 O.image_loc_x = fx * xp + cx;
00166 O.image_loc_y = fy * yp + cy;
00167 return (O);
00168 }
00169
00170 }
00171 #endif