42#include <visp3/core/vpIoTools.h>
43#include <visp3/core/vpXmlParserCamera.h>
48 std::string tmp_dir =
"C:/temp/";
50 std::string tmp_dir =
"/tmp/";
57 tmp_dir += username +
"/test_xml_parser_camera/";
59 std::cout <<
"Create: " << tmp_dir << std::endl;
63 std::cout <<
"-- Test to save/load one single camera without distortion in a single file" << std::endl;
66 std::string filename = tmp_dir +
"test_write_cam_without_distortion.xml";
69 std::cout <<
"Write to: " << filename << std::endl;
71 std::cerr <<
"Cannot save XML file: " << filename << std::endl;
80 std::cout <<
"Cam write:\n" << cam << std::endl;
81 std::cout <<
"Cam read:\n" << cam_read << std::endl;
82 if (cam != cam_read) {
83 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
93 std::cout <<
"Cam write:\n" << cam << std::endl;
94 std::cout <<
"Cam read:\n" << cam_read << std::endl;
95 if (cam != cam_read) {
96 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
103 std::cout <<
"-- Test to save/load one single camera with distortion in a single file" << std::endl;
104 std::string filename = tmp_dir +
"test_write_cam_with_distortion.xml";
109 std::cout <<
"Write to: " << filename << std::endl;
111 std::cerr <<
"Cannot save XML file: " << filename << std::endl;
120 std::cout <<
"Cam write:\n" << cam << std::endl;
121 std::cout <<
"Cam read:\n" << cam_read << std::endl;
122 if (cam != cam_read) {
123 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
133 std::cout <<
"Cam write:\n" << cam << std::endl;
134 std::cout <<
"Cam read:\n" << cam_read << std::endl;
135 if (cam != cam_read) {
136 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
143 std::cout <<
"-- Test to save/load multiple cameras with and without distortion in a single file" << std::endl;
144 std::string filename = tmp_dir +
"test_write_cam_multiple.xml";
149 std::cout <<
"Write to: " << filename <<
" camera:\n" << cam1_w_d << std::endl;
151 std::cerr <<
"Cannot save XML file: " << filename << std::endl;
160 std::cout <<
"Write to: " << filename <<
" camera:\n" << cam1_wo_d << std::endl;
162 std::cerr <<
"Cannot save XML file: " << filename << std::endl;
170 std::cout <<
"Write to: " << filename <<
" camera:\n" << cam2_w_d << std::endl;
172 std::cerr <<
"Cannot save XML file: " << filename << std::endl;
181 std::cout <<
"Write to: " << filename <<
" camera:\n" << cam2_wo_d << std::endl;
183 std::cerr <<
"Cannot save XML file: " << filename << std::endl;
192 std::cout <<
"Cam write:\n" << cam1_w_d << std::endl;
193 std::cout <<
"Cam read:\n" << cam_read << std::endl;
194 if (cam1_w_d != cam_read) {
195 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
203 std::cout <<
"Cam write:\n" << cam1_wo_d << std::endl;
204 std::cout <<
"Cam read:\n" << cam_read << std::endl;
205 if (cam1_wo_d != cam_read) {
206 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
214 std::cout <<
"Cam write:\n" << cam2_w_d << std::endl;
215 std::cout <<
"Cam read:\n" << cam_read << std::endl;
216 if (cam2_w_d != cam_read) {
217 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
225 std::cout <<
"Cam write:\n" << cam2_wo_d << std::endl;
226 std::cout <<
"Cam read:\n" << cam_read << std::endl;
227 if (cam2_wo_d != cam_read) {
228 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
235 std::cout <<
"-- Test to save/load one single camera with Kannala Brandt distortion in a single file" << std::endl;
237 std::vector<double> distortion_coeffs;
238 distortion_coeffs.push_back(-0.00297341705299914);
239 distortion_coeffs.push_back(0.0352853797376156);
240 distortion_coeffs.push_back(-0.032205019146204);
241 distortion_coeffs.push_back(0.004446716979146);
242 distortion_coeffs.push_back(0);
245 std::string filename = tmp_dir +
"test_write_cam_with_KannalaBrandt_distortion.xml";
248 std::cout <<
"Write to: " << filename << std::endl;
250 std::cerr <<
"Cannot save XML file: " << filename << std::endl;
259 std::cout <<
"Cam write:\n" << cam << std::endl;
260 std::cout <<
"Cam read:\n" << cam_read << std::endl;
261 if (cam != cam_read) {
262 std::cerr <<
"Issue when parsing XML file: " << filename << std::endl;
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
@ perspectiveProjWithDistortion
Perspective projection with distortion model.
@ ProjWithKannalaBrandtDistortion
Projection with Kannala-Brandt distortion model.
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
void initProjWithKannalaBrandtDistortion(double px, double py, double u0, double v0, const std::vector< double > &distortion_coefficients)
XML parser to load and save intrinsic camera parameters.
int save(const vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, unsigned int image_width=0, unsigned int image_height=0, const std::string &additionalInfo="", bool verbose=true)
int parse(vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, const vpCameraParameters::vpCameraParametersProjType &projModel, unsigned int image_width=0, unsigned int image_height=0, bool verbose=true)