57 vpCameraParameters cam;
60 if (cam_info.K.size() != 3 * 3 || cam_info.K[0] == 0.)
61 throw std::runtime_error (
"uncalibrated camera");
64 if (cam_info.P.size() != 3 * 4)
65 throw std::runtime_error
66 (
"camera calibration P matrix has an incorrect size");
68 if (cam_info.distortion_model.empty ())
70 const double& px = cam_info.K[0 * 3 + 0];
71 const double& py = cam_info.K[1 * 3 + 1];
72 const double& u0 = cam_info.K[0 * 3 + 2];
73 const double& v0 = cam_info.K[1 * 3 + 2];
74 cam.initPersProjWithoutDistortion(px, py, u0, v0);
80 const double& px = cam_info.P[0 * 4 + 0];
81 const double& py = cam_info.P[1 * 4 + 1];
82 const double& u0 = cam_info.P[0 * 4 + 2];
83 const double& v0 = cam_info.P[1 * 4 + 2];
84 cam.initPersProjWithoutDistortion(px, py, u0, v0);
89 throw std::runtime_error (
"unsupported distortion model");
94 sensor_msgs::CameraInfo
toSensorMsgsCameraInfo(vpCameraParameters& cam_info,
unsigned int cam_image_width,
unsigned int cam_image_height ){
95 sensor_msgs::CameraInfo ret;
97 std::vector<double> D(5);
98 D[0]=cam_info.get_kdu();
99 D[1] = D[2] = D[3] = D[4] = 0.;
106 ret.R[1 * 3 + 1] = 1.;
107 ret.R[2 * 3 + 2] = 1.;
109 ret.P[0 * 4 + 0] = cam_info.get_px();
110 ret.P[1 * 4 + 1] = cam_info.get_py();
111 ret.P[0 * 4 + 2] = cam_info.get_u0();
112 ret.P[1 * 4 + 2] = cam_info.get_v0();
113 ret.P[2 * 4 + 2] = 1;
116 ret.K[0 * 3 + 0] = cam_info.get_px();
117 ret.K[1 * 3 + 1] = cam_info.get_py();
118 ret.K[0 * 3 + 2] = cam_info.get_u0();
119 ret.K[1 * 3 + 2] = cam_info.get_v0();
120 ret.K[2 * 3 + 2] = 1;
122 ret.distortion_model =
"plumb_bob";
125 ret.width = cam_image_width;
126 ret.height = cam_image_height;