42 #include <visp3/core/vpXmlParserCamera.h>
44 #include <pugixml.hpp>
46 #include <visp3/core/vpDebug.h>
54 #define LABEL_XML_ROOT "root"
55 #define LABEL_XML_CAMERA "camera"
56 #define LABEL_XML_CAMERA_NAME "name"
57 #define LABEL_XML_WIDTH "image_width"
58 #define LABEL_XML_HEIGHT "image_height"
59 #define LABEL_XML_SUBSAMPLING_WIDTH "subsampling_width"
60 #define LABEL_XML_SUBSAMPLING_HEIGHT "subsampling_height"
61 #define LABEL_XML_FULL_WIDTH "full_width"
62 #define LABEL_XML_FULL_HEIGHT "full_height"
63 #define LABEL_XML_MODEL "model"
64 #define LABEL_XML_MODEL_TYPE "type"
65 #define LABEL_XML_U0 "u0"
66 #define LABEL_XML_V0 "v0"
67 #define LABEL_XML_PX "px"
68 #define LABEL_XML_PY "py"
69 #define LABEL_XML_KUD "kud"
70 #define LABEL_XML_KDU "kdu"
71 #define LABEL_XML_K1 "k1"
72 #define LABEL_XML_K2 "k2"
73 #define LABEL_XML_K3 "k3"
74 #define LABEL_XML_K4 "k4"
75 #define LABEL_XML_K5 "k5"
77 #define LABEL_XML_MODEL_WITHOUT_DISTORTION "perspectiveProjWithoutDistortion"
78 #define LABEL_XML_MODEL_WITH_DISTORTION "perspectiveProjWithDistortion"
79 #define LABEL_XML_MODEL_WITH_KANNALA_BRANDT_DISTORTION "ProjWithKannalaBrandtDistortion"
81 #define LABEL_XML_ADDITIONAL_INFO "additional_information"
83 #ifndef DOXYGEN_SHOULD_SKIP_THIS
84 class vpXmlParserCamera::Impl
96 CODE_XML_SUBSAMPLING_WIDTH,
97 CODE_XML_SUBSAMPLING_HEIGHT,
113 CODE_XML_ADDITIONAL_INFO
118 : camera(), camera_name(), image_width(0), image_height(0), subsampling_width(0), subsampling_height(0),
119 full_width(0), full_height(0)
125 unsigned int im_height)
127 pugi::xml_document doc;
128 if (!doc.load_file(filename.c_str())) {
132 pugi::xml_node node = doc.document_element();
137 int ret = read(node, cam_name, projModel, im_width, im_height);
160 int read(
const pugi::xml_node &node_,
const std::string &cam_name,
162 unsigned int im_height,
unsigned int subsampl_width = 0,
unsigned int subsampl_height = 0)
167 unsigned int nbCamera = 0;
169 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
170 if (node.type() != pugi::node_element)
173 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
174 prop = CODE_XML_OTHER;
177 if (prop == CODE_XML_CAMERA) {
178 if (
SEQUENCE_OK == read_camera(node, cam_name, projModel, im_width, im_height, subsampl_width, subsampl_height))
186 vpCERROR <<
"No camera parameters is available" << std::endl <<
"with your specifications" << std::endl;
187 }
else if (nbCamera > 1) {
189 vpCERROR << nbCamera <<
" sets of camera parameters are available" << std::endl
190 <<
"with your specifications : " << std::endl
191 <<
"precise your choice..." << std::endl;
213 int read_camera(
const pugi::xml_node &node_,
const std::string &cam_name,
215 unsigned int im_height,
unsigned int subsampl_width,
unsigned int subsampl_height)
219 std::string camera_name_tmp =
"";
220 unsigned int image_height_tmp = 0;
221 unsigned int image_width_tmp = 0;
222 unsigned int subsampling_width_tmp = 0;
223 unsigned int subsampling_height_tmp = 0;
226 bool projModelFound =
false;
229 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
230 if (node.type() != pugi::node_element)
233 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
234 prop = CODE_XML_OTHER;
239 case CODE_XML_CAMERA_NAME: {
240 camera_name_tmp = node.text().as_string();
241 std::cout <<
"Found camera with name: \"" << camera_name_tmp <<
"\"" << std::endl;
245 image_width_tmp = node.text().as_uint();
248 case CODE_XML_HEIGHT:
249 image_height_tmp = node.text().as_uint();
251 case CODE_XML_SUBSAMPLING_WIDTH:
252 subsampling_width_tmp = node.text().as_uint();
254 case CODE_XML_SUBSAMPLING_HEIGHT:
255 subsampling_height_tmp = node.text().as_uint();
259 back = read_camera_model(node, cam_tmp_model);
261 cam_tmp = cam_tmp_model;
262 projModelFound =
true;
266 case CODE_XML_ADDITIONAL_INFO:
271 case CODE_XML_CAMERA:
272 case CODE_XML_FULL_HEIGHT:
273 case CODE_XML_FULL_WIDTH:
274 case CODE_XML_MODEL_TYPE:
293 bool test_subsampling_width =
true;
294 bool test_subsampling_height =
true;
296 if (subsampling_width) {
297 test_subsampling_width = (abs((
int)subsampl_width - (
int)subsampling_width_tmp) <
298 (allowedPixelDiffOnImageSize * (int)(subsampling_width_tmp / subsampling_width)));
300 if (subsampling_height) {
301 test_subsampling_height = (abs((
int)subsampl_height - (
int)subsampling_height_tmp) <
302 (allowedPixelDiffOnImageSize * (int)(subsampling_height_tmp / subsampling_height)));
304 if (!((projModelFound ==
true) && (cam_name == camera_name_tmp) &&
305 (abs((
int)im_width - (int)image_width_tmp) < allowedPixelDiffOnImageSize || im_width == 0) &&
306 (abs((
int)im_height - (int)image_height_tmp) < allowedPixelDiffOnImageSize || im_height == 0) &&
307 (test_subsampling_width) && (test_subsampling_height))) {
311 camera_name = camera_name_tmp;
312 image_width = image_width_tmp;
313 image_height = image_height_tmp;
314 subsampling_width = subsampling_width_tmp;
315 subsampling_height = subsampling_height_tmp;
316 full_width = subsampling_width_tmp * image_width_tmp;
317 full_height = subsampling_height_tmp * image_height_tmp;
335 std::string model_type =
"";
336 double u0 = cam_tmp.
get_u0();
337 double v0 = cam_tmp.
get_v0();
338 double px = cam_tmp.
get_px();
339 double py = cam_tmp.
get_py();
340 double kud = cam_tmp.
get_kud();
341 double kdu = cam_tmp.
get_kdu();
342 std::vector<double> distortion_coeffs;
346 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
348 if (node.type() != pugi::node_element)
351 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
352 prop = CODE_XML_OTHER;
357 case CODE_XML_MODEL_TYPE: {
358 model_type = node.text().as_string();
360 validation = validation | 0x01;
363 u0 = node.text().as_double();
365 validation = validation | 0x02;
368 v0 = node.text().as_double();
370 validation = validation | 0x04;
373 px = node.text().as_double();
375 validation = validation | 0x08;
378 py = node.text().as_double();
380 validation = validation | 0x10;
383 kud = node.text().as_double();
385 validation = validation | 0x20;
388 kdu = node.text().as_double();
390 validation = validation | 0x40;
393 distortion_coeffs.push_back(node.text().as_double());
395 validation = validation | 0x20;
398 distortion_coeffs.push_back(node.text().as_double());
400 validation = validation | 0x40;
403 distortion_coeffs.push_back(node.text().as_double());
405 validation = validation | 0x80;
408 distortion_coeffs.push_back(node.text().as_double());
410 validation = validation | 0x100;
413 distortion_coeffs.push_back(node.text().as_double());
415 validation = validation | 0x200;
419 case CODE_XML_CAMERA:
420 case CODE_XML_CAMERA_NAME:
421 case CODE_XML_HEIGHT:
423 case CODE_XML_SUBSAMPLING_WIDTH:
424 case CODE_XML_SUBSAMPLING_HEIGHT:
425 case CODE_XML_FULL_HEIGHT:
426 case CODE_XML_FULL_WIDTH:
428 case CODE_XML_ADDITIONAL_INFO:
435 if (model_type.empty()) {
436 vpERROR_TRACE(
"projection model type doesn't match with any known model !");
440 if (!strcmp(model_type.c_str(), LABEL_XML_MODEL_WITHOUT_DISTORTION)) {
441 if (nb != 5 || validation != 0x001F) {
442 vpCERROR <<
"ERROR in 'model' field:\n";
443 vpCERROR <<
"it must contain 5 parameters\n";
448 }
else if (!strcmp(model_type.c_str(), LABEL_XML_MODEL_WITH_DISTORTION)) {
449 if (nb != 7 || validation != 0x7F) {
450 vpCERROR <<
"ERROR in 'model' field:\n";
451 vpCERROR <<
"it must contain 7 parameters\n";
456 }
else if (!strcmp(model_type.c_str(), LABEL_XML_MODEL_WITH_KANNALA_BRANDT_DISTORTION)) {
457 if (nb != 10 || validation != 0x3FF) {
458 vpCERROR <<
"ERROR in 'model' field:\n";
459 vpCERROR <<
"it must contain 10 parameters\n";
461 std::vector<double> fixed_distortion_coeffs;
467 int check = validation / 32;
470 for (
int i = 0; i < 5; i++) {
473 fixed_distortion_coeffs.push_back(0.);
475 fixed_distortion_coeffs.push_back(distortion_coeffs[j++]);
484 vpERROR_TRACE(
"projection model type doesn't match with any known model !");
492 unsigned int im_width,
unsigned int im_height,
const std::string &additionalInfo)
494 pugi::xml_document doc;
497 if (!doc.load_file(filename.c_str(), pugi::parse_default | pugi::parse_comments)) {
498 node = doc.append_child(pugi::node_declaration);
499 node.append_attribute(
"version") =
"1.0";
500 node = doc.append_child(LABEL_XML_ROOT);
501 pugi::xml_node nodeComment = node.append_child(pugi::node_comment);
502 nodeComment.set_value(
"This file stores intrinsic camera parameters used\n"
503 " in the vpCameraParameters Class of ViSP available\n"
504 " at https://visp.inria.fr/download/ .\n"
505 " It can be read with the parse method of\n"
506 " the vpXmlParserCamera class.");
509 node = doc.document_element();
516 int nbCamera = count(node, cam_name, cam.
get_projModel(), im_width, im_height);
521 pugi::xml_node nodeCamera = find_camera(node, cam_name, im_width, im_height);
523 write(node, cam_name, im_width, im_height);
525 write_camera(nodeCamera);
528 if (!additionalInfo.empty()) {
530 nodeCamera = find_camera(node, cam_name, im_width, im_height);
533 pugi::xml_node nodeAdditionalInfo = find_additional_info(nodeCamera);
535 if (!nodeAdditionalInfo) {
537 pugi::xml_node node_comment = nodeCamera.append_child(pugi::node_comment);
538 node_comment.set_value(
"Additional information");
540 nodeAdditionalInfo = nodeCamera.append_child(LABEL_XML_ADDITIONAL_INFO);
543 if (nodeAdditionalInfo) {
545 pugi::xml_document tmpDoc;
546 if (tmpDoc.load_string(additionalInfo.c_str())) {
547 for (node = tmpDoc.first_child(); node; node = node.next_sibling()) {
548 nodeAdditionalInfo.append_copy(node);
554 doc.save_file(filename.c_str(), PUGIXML_TEXT(
" "));
576 int count(
const pugi::xml_node &node_,
const std::string &cam_name,
578 unsigned int im_height,
unsigned int subsampl_width = 0,
unsigned int subsampl_height = 0)
583 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
584 if (node.type() != pugi::node_element)
587 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
588 prop = CODE_XML_OTHER;
591 if (prop == CODE_XML_CAMERA) {
592 if (
SEQUENCE_OK == read_camera(node, cam_name, projModel, im_width, im_height, subsampl_width, subsampl_height))
616 pugi::xml_node find_camera(
const pugi::xml_node &node_,
const std::string &cam_name,
unsigned int im_width,
617 unsigned int im_height,
unsigned int subsampl_width = 0,
unsigned int subsampl_height = 0)
621 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
622 if (node.type() != pugi::node_element)
625 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
626 prop = CODE_XML_OTHER;
628 if (prop == CODE_XML_CAMERA) {
629 if (
SEQUENCE_OK == read_camera_header(node, cam_name, im_width, im_height, subsampl_width, subsampl_height)) {
634 return pugi::xml_node();
652 int read_camera_header(
const pugi::xml_node &node_,
const std::string &cam_name,
unsigned int im_width,
653 unsigned int im_height,
unsigned int subsampl_width = 0,
unsigned int subsampl_height = 0)
657 std::string camera_name_tmp =
"";
658 unsigned int image_height_tmp = 0;
659 unsigned int image_width_tmp = 0;
660 unsigned int subsampling_width_tmp = 0;
661 unsigned int subsampling_height_tmp = 0;
664 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
665 if (node.type() != pugi::node_element)
667 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
668 prop = CODE_XML_OTHER;
673 case CODE_XML_CAMERA_NAME:
674 camera_name_tmp = node.text().as_string();
678 image_width_tmp = node.text().as_uint();
681 case CODE_XML_HEIGHT:
682 image_height_tmp = node.text().as_uint();
685 case CODE_XML_SUBSAMPLING_WIDTH:
686 subsampling_width_tmp = node.text().as_uint();
689 case CODE_XML_SUBSAMPLING_HEIGHT:
690 subsampling_height_tmp = node.text().as_uint();
696 case CODE_XML_ADDITIONAL_INFO:
701 case CODE_XML_CAMERA:
702 case CODE_XML_FULL_HEIGHT:
703 case CODE_XML_FULL_WIDTH:
704 case CODE_XML_MODEL_TYPE:
716 if (!((cam_name == camera_name_tmp) && (im_width == image_width_tmp || im_width == 0) &&
717 (im_height == image_height_tmp || im_height == 0) &&
718 (subsampl_width == subsampling_width_tmp || subsampl_width == 0) &&
719 (subsampl_height == subsampling_height_tmp || subsampl_height == 0))) {
740 int write(pugi::xml_node &node,
const std::string &cam_name,
unsigned int im_width,
unsigned int im_height,
741 unsigned int subsampl_width = 0,
unsigned int subsampl_height = 0)
746 pugi::xml_node node_camera = node.append_child(LABEL_XML_CAMERA);
748 pugi::xml_node node_tmp;
751 if (!cam_name.empty()) {
752 node_tmp = node_camera.append_child(pugi::node_comment);
753 node_tmp.set_value(
"Name of the camera");
754 node_tmp = node_camera.append_child(LABEL_XML_CAMERA_NAME);
755 node_tmp.append_child(pugi::node_pcdata).set_value(cam_name.c_str());
758 if (im_width != 0 || im_height != 0) {
759 node_tmp = node_camera.append_child(pugi::node_comment);
760 node_tmp.set_value(
"Size of the image on which camera "
761 "calibration was performed");
764 node_tmp = node_camera.append_child(LABEL_XML_WIDTH);
765 node_tmp.append_child(pugi::node_pcdata).text() = im_width;
768 node_tmp = node_camera.append_child(LABEL_XML_HEIGHT);
769 node_tmp.append_child(pugi::node_pcdata).text() = im_height;
770 if (subsampling_width != 0 || subsampling_height != 0) {
771 node_tmp = node_camera.append_child(pugi::node_comment);
772 node_tmp.set_value(
"Subsampling used to obtain the "
773 "current size of the image.");
776 node_tmp = node_camera.append_child(LABEL_XML_SUBSAMPLING_WIDTH);
777 node_tmp.append_child(pugi::node_pcdata).text() = subsampl_width;
779 node_tmp = node_camera.append_child(LABEL_XML_SUBSAMPLING_HEIGHT);
780 node_tmp.append_child(pugi::node_pcdata).text() = subsampl_height;
781 node_tmp = node_camera.append_child(pugi::node_comment);
782 node_tmp.set_value(
"The full size is the sensor size actually used to "
783 "grab the image. full_width = subsampling_width * "
787 node_tmp = node_camera.append_child(LABEL_XML_FULL_WIDTH);
788 node_tmp.append_child(pugi::node_pcdata).text() = im_width * subsampl_width;
790 node_tmp = node_camera.append_child(LABEL_XML_FULL_HEIGHT);
791 node_tmp.append_child(pugi::node_pcdata).text() = im_height * subsampl_height;
795 node_tmp = node_camera.append_child(pugi::node_comment);
796 node_tmp.set_value(
"Intrinsic camera parameters "
797 "computed for each projection model");
799 back = write_camera(node_camera);
809 int write_camera(pugi::xml_node &node_camera)
811 pugi::xml_node node_model;
812 pugi::xml_node node_tmp;
815 switch (camera.get_projModel()) {
818 node_model = node_camera.append_child(LABEL_XML_MODEL);
820 node_tmp = node_model.append_child(pugi::node_comment);
821 node_tmp.set_value(
"Projection model type");
824 node_tmp = node_model.append_child(LABEL_XML_MODEL_TYPE);
825 node_tmp.append_child(pugi::node_pcdata).set_value(LABEL_XML_MODEL_WITHOUT_DISTORTION);
827 node_tmp = node_model.append_child(pugi::node_comment);
828 node_tmp.set_value(
"Pixel ratio");
830 node_tmp = node_model.append_child(LABEL_XML_PX);
831 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_px();
833 node_tmp = node_model.append_child(LABEL_XML_PY);
834 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_py();
836 node_tmp = node_model.append_child(pugi::node_comment);
837 node_tmp.set_value(
"Principal point");
840 node_tmp = node_model.append_child(LABEL_XML_U0);
841 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_u0();
843 node_tmp = node_model.append_child(LABEL_XML_V0);
844 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_v0();
850 node_model = node_camera.append_child(LABEL_XML_MODEL);
852 node_tmp = node_model.append_child(pugi::node_comment);
853 node_tmp.set_value(
"Projection model type");
855 node_tmp = node_model.append_child(LABEL_XML_MODEL_TYPE);
856 node_tmp.append_child(pugi::node_pcdata).set_value(LABEL_XML_MODEL_WITH_DISTORTION);
858 node_tmp = node_model.append_child(pugi::node_comment);
859 node_tmp.set_value(
"Pixel ratio");
861 node_tmp = node_model.append_child(LABEL_XML_PX);
862 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_px();
864 node_tmp = node_model.append_child(LABEL_XML_PY);
865 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_py();
867 node_tmp = node_model.append_child(pugi::node_comment);
868 node_tmp.set_value(
"Principal point");
870 node_tmp = node_model.append_child(LABEL_XML_U0);
871 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_u0();
873 node_tmp = node_model.append_child(LABEL_XML_V0);
874 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_v0();
877 node_tmp = node_model.append_child(pugi::node_comment);
878 node_tmp.set_value(
"Undistorted to distorted distortion parameter");
879 node_tmp = node_model.append_child(LABEL_XML_KUD);
880 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_kud();
883 node_tmp = node_model.append_child(pugi::node_comment);
884 node_tmp.set_value(
"Distorted to undistorted distortion parameter");
885 node_tmp = node_model.append_child(LABEL_XML_KDU);
886 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_kdu();
892 node_model = node_camera.append_child(LABEL_XML_MODEL);
894 node_tmp = node_model.append_child(pugi::node_comment);
895 node_tmp.set_value(
"Projection model type");
897 node_tmp = node_model.append_child(LABEL_XML_MODEL_TYPE);
898 node_tmp.append_child(pugi::node_pcdata).set_value(LABEL_XML_MODEL_WITH_KANNALA_BRANDT_DISTORTION);
900 node_tmp = node_model.append_child(pugi::node_comment);
901 node_tmp.set_value(
"Pixel ratio");
903 node_tmp = node_model.append_child(LABEL_XML_PX);
904 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_px();
906 node_tmp = node_model.append_child(LABEL_XML_PY);
907 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_py();
909 node_tmp = node_model.append_child(pugi::node_comment);
910 node_tmp.set_value(
"Principal point");
912 node_tmp = node_model.append_child(LABEL_XML_U0);
913 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_u0();
915 node_tmp = node_model.append_child(LABEL_XML_V0);
916 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_v0();
919 std::vector<double> distortion_coefs = camera.getKannalaBrandtDistortionCoefficients();
921 if (distortion_coefs.size() != 5)
922 std::cout <<
"Make sure to have 5 distortion coefficients for Kannala-Brandt distortions." << std::endl;
924 node_tmp = node_model.append_child(pugi::node_comment);
925 node_tmp.set_value(
"Distortion coefficients");
926 node_tmp = node_model.append_child(LABEL_XML_K1);
927 distortion_coefs.size() == 0 ? node_tmp.append_child(pugi::node_pcdata).text() = 0
928 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[0];
929 node_tmp = node_model.append_child(LABEL_XML_K2);
930 distortion_coefs.size() <= 1 ? node_tmp.append_child(pugi::node_pcdata).text() = 0
931 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[1];
932 node_tmp = node_model.append_child(LABEL_XML_K3);
933 distortion_coefs.size() <= 2 ? node_tmp.append_child(pugi::node_pcdata).text() = 0
934 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[2];
935 node_tmp = node_model.append_child(LABEL_XML_K4);
936 distortion_coefs.size() <= 3 ? node_tmp.append_child(pugi::node_pcdata).text() = 0
937 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[3];
938 node_tmp = node_model.append_child(LABEL_XML_K5);
939 distortion_coefs.size() <= 4 ? node_tmp.append_child(pugi::node_pcdata).text() = 0
940 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[4];
953 pugi::xml_node find_additional_info(
const pugi::xml_node &node_)
957 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
958 if (node.type() != pugi::node_element) {
962 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
963 prop = CODE_XML_OTHER;
966 if (prop == CODE_XML_ADDITIONAL_INFO) {
972 return pugi::xml_node();
983 vpXmlCodeType val_int = CODE_XML_BAD;
986 if (!strcmp(str, LABEL_XML_CAMERA)) {
987 val_int = CODE_XML_CAMERA;
988 }
else if (!strcmp(str, LABEL_XML_CAMERA_NAME)) {
989 val_int = CODE_XML_CAMERA_NAME;
990 }
else if (!strcmp(str, LABEL_XML_MODEL)) {
991 val_int = CODE_XML_MODEL;
992 }
else if (!strcmp(str, LABEL_XML_MODEL_TYPE)) {
993 val_int = CODE_XML_MODEL_TYPE;
994 }
else if (!strcmp(str, LABEL_XML_WIDTH)) {
995 val_int = CODE_XML_WIDTH;
996 }
else if (!strcmp(str, LABEL_XML_HEIGHT)) {
997 val_int = CODE_XML_HEIGHT;
998 }
else if (!strcmp(str, LABEL_XML_SUBSAMPLING_WIDTH)) {
999 val_int = CODE_XML_SUBSAMPLING_WIDTH;
1000 }
else if (!strcmp(str, LABEL_XML_SUBSAMPLING_HEIGHT)) {
1001 val_int = CODE_XML_SUBSAMPLING_HEIGHT;
1002 }
else if (!strcmp(str, LABEL_XML_FULL_WIDTH)) {
1003 val_int = CODE_XML_FULL_WIDTH;
1004 }
else if (!strcmp(str, LABEL_XML_FULL_HEIGHT)) {
1005 val_int = CODE_XML_FULL_HEIGHT;
1006 }
else if (!strcmp(str, LABEL_XML_U0)) {
1007 val_int = CODE_XML_U0;
1008 }
else if (!strcmp(str, LABEL_XML_V0)) {
1009 val_int = CODE_XML_V0;
1010 }
else if (!strcmp(str, LABEL_XML_PX)) {
1011 val_int = CODE_XML_PX;
1012 }
else if (!strcmp(str, LABEL_XML_PY)) {
1013 val_int = CODE_XML_PY;
1014 }
else if (!strcmp(str, LABEL_XML_KUD)) {
1015 val_int = CODE_XML_KUD;
1016 }
else if (!strcmp(str, LABEL_XML_KDU)) {
1017 val_int = CODE_XML_KDU;
1018 }
else if (!strcmp(str, LABEL_XML_K1)) {
1019 val_int = CODE_XML_K1;
1020 }
else if (!strcmp(str, LABEL_XML_K2)) {
1021 val_int = CODE_XML_K2;
1022 }
else if (!strcmp(str, LABEL_XML_K3)) {
1023 val_int = CODE_XML_K3;
1024 }
else if (!strcmp(str, LABEL_XML_K4)) {
1025 val_int = CODE_XML_K4;
1026 }
else if (!strcmp(str, LABEL_XML_K5)) {
1027 val_int = CODE_XML_K5;
1028 }
else if (!strcmp(str, LABEL_XML_ADDITIONAL_INFO)) {
1029 val_int = CODE_XML_ADDITIONAL_INFO;
1031 val_int = CODE_XML_OTHER;
1040 unsigned int getHeight()
const {
return image_height; }
1043 unsigned int getWidth()
const {
return image_width; }
1045 void setCameraName(
const std::string &name) { camera_name = name; }
1046 void setHeight(
unsigned int height) { image_height = height; }
1049 void setWidth(
unsigned int width) { image_width = width; }
1053 std::string camera_name;
1054 unsigned int image_width;
1055 unsigned int image_height;
1056 unsigned int subsampling_width;
1057 unsigned int subsampling_height;
1058 unsigned int full_width;
1059 unsigned int full_height;
1063 static const int allowedPixelDiffOnImageSize = 15;
1087 unsigned int im_height)
1089 return m_impl->parse(cam, filename, cam_name, projModel, im_width, im_height);
1136 unsigned int im_width,
unsigned int im_height,
const std::string &additionalInfo)
1138 return m_impl->save(cam, filename, cam_name, im_width, im_height, additionalInfo);
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
vpCameraParametersProjType
@ perspectiveProjWithDistortion
@ ProjWithKannalaBrandtDistortion
@ perspectiveProjWithoutDistortion
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
vpCameraParametersProjType get_projModel() const
void initProjWithKannalaBrandtDistortion(double px, double py, double u0, double v0, const std::vector< double > &distortion_coefficients)
void setSubsampling_width(unsigned int subsampling)
void setWidth(unsigned int width)
unsigned int getHeight() const
vpCameraParameters getCameraParameters() const
unsigned int getWidth() const
void setSubsampling_height(unsigned int subsampling)
void setCameraName(const std::string &name)
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="")
void setHeight(unsigned int height)
unsigned int getSubsampling_height() const
unsigned int getSubsampling_width() const
std::string getCameraName() const
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)