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
117 Impl() : camera(), camera_name(), image_width(0), image_height(0), subsampling_width(0),
118 subsampling_height(0), full_width(0), full_height(0)
124 unsigned int im_width,
unsigned int im_height)
126 pugi::xml_document doc;
127 if (!doc.load_file(filename.c_str())) {
131 pugi::xml_node node = doc.document_element();
136 int ret = read(node, cam_name, projModel, im_width, im_height);
159 int read(
const pugi::xml_node &node_,
const std::string &cam_name,
161 unsigned int im_width,
unsigned int im_height,
162 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) {
179 read_camera(node, cam_name, projModel, im_width, im_height, subsampl_width, subsampl_height))
187 vpCERROR <<
"No camera parameters is available" << std::endl <<
"with your specifications" << std::endl;
188 }
else if (nbCamera > 1) {
190 vpCERROR << nbCamera <<
" sets of camera parameters are available" << std::endl
191 <<
"with your specifications : " << std::endl
192 <<
"precise your choice..." << std::endl;
214 int read_camera(
const pugi::xml_node &node_,
const std::string &cam_name,
216 unsigned int im_width,
unsigned int im_height,
217 unsigned int subsampl_width,
unsigned int subsampl_height)
221 std::string camera_name_tmp =
"";
222 unsigned int image_height_tmp = 0;
223 unsigned int image_width_tmp = 0;
224 unsigned int subsampling_width_tmp = 0;
225 unsigned int subsampling_height_tmp = 0;
228 bool projModelFound =
false;
231 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
232 if (node.type() != pugi::node_element)
235 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
236 prop = CODE_XML_OTHER;
241 case CODE_XML_CAMERA_NAME: {
242 camera_name_tmp = node.text().as_string();
243 std::cout <<
"Found camera with name: \"" << camera_name_tmp <<
"\"" << std::endl;
247 image_width_tmp = node.text().as_uint();
250 case CODE_XML_HEIGHT:
251 image_height_tmp = node.text().as_uint();
253 case CODE_XML_SUBSAMPLING_WIDTH:
254 subsampling_width_tmp = node.text().as_uint();
256 case CODE_XML_SUBSAMPLING_HEIGHT:
257 subsampling_height_tmp = node.text().as_uint();
261 back = read_camera_model(node, cam_tmp_model);
263 cam_tmp = cam_tmp_model;
264 projModelFound =
true;
268 case CODE_XML_ADDITIONAL_INFO:
273 case CODE_XML_CAMERA:
274 case CODE_XML_FULL_HEIGHT:
275 case CODE_XML_FULL_WIDTH:
276 case CODE_XML_MODEL_TYPE:
295 bool test_subsampling_width =
true;
296 bool test_subsampling_height =
true;
298 if (subsampling_width) {
299 test_subsampling_width = (abs((
int)subsampl_width - (
int)subsampling_width_tmp) <
300 (allowedPixelDiffOnImageSize * (int)(subsampling_width_tmp / subsampling_width)));
302 if (subsampling_height) {
303 test_subsampling_height = (abs((
int)subsampl_height - (
int)subsampling_height_tmp) <
304 (allowedPixelDiffOnImageSize * (int)(subsampling_height_tmp / subsampling_height)));
306 if (!((projModelFound ==
true) && (cam_name == camera_name_tmp) &&
307 (abs((
int)im_width - (int)image_width_tmp) < allowedPixelDiffOnImageSize || im_width == 0) &&
308 (abs((
int)im_height - (int)image_height_tmp) < allowedPixelDiffOnImageSize || im_height == 0) &&
309 (test_subsampling_width) && (test_subsampling_height))) {
313 camera_name = camera_name_tmp;
314 image_width = image_width_tmp;
315 image_height = image_height_tmp;
316 subsampling_width = subsampling_width_tmp;
317 subsampling_height = subsampling_height_tmp;
318 full_width = subsampling_width_tmp * image_width_tmp;
319 full_height = subsampling_height_tmp * image_height_tmp;
338 std::string model_type =
"";
339 double u0 = cam_tmp.
get_u0();
340 double v0 = cam_tmp.
get_v0();
341 double px = cam_tmp.
get_px();
342 double py = cam_tmp.
get_py();
343 double kud = cam_tmp.
get_kud();
344 double kdu = cam_tmp.
get_kdu();
345 std::vector<double> distortion_coeffs;
349 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
351 if (node.type() != pugi::node_element)
354 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
355 prop = CODE_XML_OTHER;
360 case CODE_XML_MODEL_TYPE: {
361 model_type = node.text().as_string();
363 validation = validation | 0x01;
366 u0 = node.text().as_double();
368 validation = validation | 0x02;
371 v0 = node.text().as_double();
373 validation = validation | 0x04;
376 px = node.text().as_double();
378 validation = validation | 0x08;
381 py = node.text().as_double();
383 validation = validation | 0x10;
386 kud = node.text().as_double();
388 validation = validation | 0x20;
391 kdu = node.text().as_double();
393 validation = validation | 0x40;
396 distortion_coeffs.push_back(node.text().as_double());
398 validation = validation | 0x20;
401 distortion_coeffs.push_back(node.text().as_double());
403 validation = validation | 0x40;
406 distortion_coeffs.push_back(node.text().as_double());
408 validation = validation | 0x80;
411 distortion_coeffs.push_back(node.text().as_double());
413 validation = validation | 0x100;
416 distortion_coeffs.push_back(node.text().as_double());
418 validation = validation | 0x200;
422 case CODE_XML_CAMERA:
423 case CODE_XML_CAMERA_NAME:
424 case CODE_XML_HEIGHT:
426 case CODE_XML_SUBSAMPLING_WIDTH:
427 case CODE_XML_SUBSAMPLING_HEIGHT:
428 case CODE_XML_FULL_HEIGHT:
429 case CODE_XML_FULL_WIDTH:
431 case CODE_XML_ADDITIONAL_INFO:
438 if (model_type.empty()) {
439 vpERROR_TRACE(
"projection model type doesn't match with any known model !");
443 if (!strcmp(model_type.c_str(), LABEL_XML_MODEL_WITHOUT_DISTORTION)) {
444 if (nb != 5 || validation != 0x001F) {
445 vpCERROR <<
"ERROR in 'model' field:\n";
446 vpCERROR <<
"it must contain 5 parameters\n";
451 }
else if (!strcmp(model_type.c_str(), LABEL_XML_MODEL_WITH_DISTORTION)) {
452 if (nb != 7 || validation != 0x7F) {
453 vpCERROR <<
"ERROR in 'model' field:\n";
454 vpCERROR <<
"it must contain 7 parameters\n";
459 }
else if (!strcmp(model_type.c_str(), LABEL_XML_MODEL_WITH_KANNALA_BRANDT_DISTORTION)) {
460 if (nb != 10 || validation != 0x3FF) {
461 vpCERROR <<
"ERROR in 'model' field:\n";
462 vpCERROR <<
"it must contain 10 parameters\n";
464 std::vector<double> fixed_distortion_coeffs;
470 int check = validation / 32;
473 for(
int i = 0; i < 5; i++)
477 fixed_distortion_coeffs.push_back(0.);
479 fixed_distortion_coeffs.push_back(distortion_coeffs[j++]);
488 vpERROR_TRACE(
"projection model type doesn't match with any known model !");
496 unsigned int im_width,
unsigned int im_height,
497 const std::string &additionalInfo)
499 pugi::xml_document doc;
502 if (!doc.load_file(filename.c_str(), pugi::parse_default | pugi::parse_comments)) {
503 node = doc.append_child(pugi::node_declaration);
504 node.append_attribute(
"version") =
"1.0";
505 node = doc.append_child(LABEL_XML_ROOT);
506 pugi::xml_node nodeComment = node.append_child(pugi::node_comment);
507 nodeComment.set_value(
"This file stores intrinsic camera parameters used\n" 508 " in the vpCameraParameters Class of ViSP available\n" 509 " at https://visp.inria.fr/download/ .\n" 510 " It can be read with the parse method of\n" 511 " the vpXmlParserCamera class.");
514 node = doc.document_element();
521 int nbCamera = count(node, cam_name, cam.
get_projModel(), im_width, im_height);
526 pugi::xml_node nodeCamera = find_camera(node, cam_name, im_width, im_height);
528 write(node, cam_name, im_width, im_height);
530 write_camera(nodeCamera);
533 if (!additionalInfo.empty()) {
535 nodeCamera = find_camera(node, cam_name, im_width, im_height);
538 pugi::xml_node nodeAdditionalInfo = find_additional_info(nodeCamera);
540 if (!nodeAdditionalInfo) {
542 pugi::xml_node node_comment = nodeCamera.append_child(pugi::node_comment);
543 node_comment.set_value(
"Additional information");
545 nodeAdditionalInfo = nodeCamera.append_child(LABEL_XML_ADDITIONAL_INFO);
548 if (nodeAdditionalInfo) {
550 pugi::xml_document tmpDoc;
551 if (tmpDoc.load_string(additionalInfo.c_str())) {
552 for (node = tmpDoc.first_child(); node; node = node.next_sibling()) {
553 nodeAdditionalInfo.append_copy(node);
559 doc.save_file(filename.c_str(), PUGIXML_TEXT(
" "));
581 int count(
const pugi::xml_node &node_,
const std::string &cam_name,
583 unsigned int im_width,
unsigned int im_height,
584 unsigned int subsampl_width=0,
unsigned int subsampl_height=0)
589 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
590 if (node.type() != pugi::node_element)
593 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
594 prop = CODE_XML_OTHER;
597 if (prop == CODE_XML_CAMERA) {
599 read_camera(node, cam_name, projModel, im_width, im_height, subsampl_width, subsampl_height))
623 pugi::xml_node find_camera(
const pugi::xml_node &node_,
const std::string &cam_name,
624 unsigned int im_width,
unsigned int im_height,
625 unsigned int subsampl_width=0,
unsigned int subsampl_height=0)
629 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
630 if (node.type() != pugi::node_element)
633 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
634 prop = CODE_XML_OTHER;
636 if (prop == CODE_XML_CAMERA) {
637 if (
SEQUENCE_OK == read_camera_header(node, cam_name, im_width, im_height, subsampl_width, subsampl_height)) {
642 return pugi::xml_node();
660 int read_camera_header(
const pugi::xml_node &node_,
const std::string &cam_name,
661 unsigned int im_width,
unsigned int im_height,
662 unsigned int subsampl_width=0,
unsigned int subsampl_height=0)
666 std::string camera_name_tmp =
"";
667 unsigned int image_height_tmp = 0;
668 unsigned int image_width_tmp = 0;
669 unsigned int subsampling_width_tmp = 0;
670 unsigned int subsampling_height_tmp = 0;
673 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
674 if (node.type() != pugi::node_element)
676 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
677 prop = CODE_XML_OTHER;
682 case CODE_XML_CAMERA_NAME:
683 camera_name_tmp = node.text().as_string();
687 image_width_tmp = node.text().as_uint();
690 case CODE_XML_HEIGHT:
691 image_height_tmp = node.text().as_uint();
694 case CODE_XML_SUBSAMPLING_WIDTH:
695 subsampling_width_tmp = node.text().as_uint();
698 case CODE_XML_SUBSAMPLING_HEIGHT:
699 subsampling_height_tmp = node.text().as_uint();
705 case CODE_XML_ADDITIONAL_INFO:
710 case CODE_XML_CAMERA:
711 case CODE_XML_FULL_HEIGHT:
712 case CODE_XML_FULL_WIDTH:
713 case CODE_XML_MODEL_TYPE:
725 if (!((cam_name == camera_name_tmp) && (im_width == image_width_tmp || im_width == 0) &&
726 (im_height == image_height_tmp || im_height == 0) &&
727 (subsampl_width == subsampling_width_tmp || subsampl_width == 0) &&
728 (subsampl_height == subsampling_height_tmp || subsampl_height == 0))) {
749 int write(pugi::xml_node &node,
const std::string &cam_name,
unsigned int im_width,
750 unsigned int im_height,
unsigned int subsampl_width=0,
751 unsigned int subsampl_height=0)
756 pugi::xml_node node_camera = node.append_child(LABEL_XML_CAMERA);
758 pugi::xml_node node_tmp;
761 if (!cam_name.empty()) {
762 node_tmp = node_camera.append_child(pugi::node_comment);
763 node_tmp.set_value(
"Name of the camera");
764 node_tmp = node_camera.append_child(LABEL_XML_CAMERA_NAME);
765 node_tmp.append_child(pugi::node_pcdata).set_value(cam_name.c_str());
768 if (im_width != 0 || im_height != 0) {
769 node_tmp = node_camera.append_child(pugi::node_comment);
770 node_tmp.set_value(
"Size of the image on which camera " 771 "calibration was performed");
774 node_tmp = node_camera.append_child(LABEL_XML_WIDTH);
775 node_tmp.append_child(pugi::node_pcdata).text() = im_width;
778 node_tmp = node_camera.append_child(LABEL_XML_HEIGHT);
779 node_tmp.append_child(pugi::node_pcdata).text() = im_height;
780 if (subsampling_width != 0 || subsampling_height != 0) {
781 node_tmp = node_camera.append_child(pugi::node_comment);
782 node_tmp.set_value(
"Subsampling used to obtain the " 783 "current size of the image.");
786 node_tmp = node_camera.append_child(LABEL_XML_SUBSAMPLING_WIDTH);
787 node_tmp.append_child(pugi::node_pcdata).text() = subsampl_width;
789 node_tmp = node_camera.append_child(LABEL_XML_SUBSAMPLING_HEIGHT);
790 node_tmp.append_child(pugi::node_pcdata).text() = subsampl_height;
791 node_tmp = node_camera.append_child(pugi::node_comment);
792 node_tmp.set_value(
"The full size is the sensor size actually used to " 793 "grab the image. full_width = subsampling_width * " 797 node_tmp = node_camera.append_child(LABEL_XML_FULL_WIDTH);
798 node_tmp.append_child(pugi::node_pcdata).text() = im_width * subsampl_width;
800 node_tmp = node_camera.append_child(LABEL_XML_FULL_HEIGHT);
801 node_tmp.append_child(pugi::node_pcdata).text() = im_height * subsampl_height;
805 node_tmp = node_camera.append_child(pugi::node_comment);
806 node_tmp.set_value(
"Intrinsic camera parameters " 807 "computed for each projection model");
809 back = write_camera(node_camera);
819 int write_camera(pugi::xml_node &node_camera)
821 pugi::xml_node node_model;
822 pugi::xml_node node_tmp;
825 switch (camera.get_projModel()) {
828 node_model = node_camera.append_child(LABEL_XML_MODEL);
830 node_tmp = node_model.append_child(pugi::node_comment);
831 node_tmp.set_value(
"Projection model type");
834 node_tmp = node_model.append_child(LABEL_XML_MODEL_TYPE);
835 node_tmp.append_child(pugi::node_pcdata).set_value(LABEL_XML_MODEL_WITHOUT_DISTORTION);
837 node_tmp = node_model.append_child(pugi::node_comment);
838 node_tmp.set_value(
"Pixel ratio");
840 node_tmp = node_model.append_child(LABEL_XML_PX);
841 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_px();
843 node_tmp = node_model.append_child(LABEL_XML_PY);
844 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_py();
846 node_tmp = node_model.append_child(pugi::node_comment);
847 node_tmp.set_value(
"Principal point");
850 node_tmp = node_model.append_child(LABEL_XML_U0);
851 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_u0();
853 node_tmp = node_model.append_child(LABEL_XML_V0);
854 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_v0();
860 node_model = node_camera.append_child(LABEL_XML_MODEL);
862 node_tmp = node_model.append_child(pugi::node_comment);
863 node_tmp.set_value(
"Projection model type");
865 node_tmp = node_model.append_child(LABEL_XML_MODEL_TYPE);
866 node_tmp.append_child(pugi::node_pcdata).set_value(LABEL_XML_MODEL_WITH_DISTORTION);
868 node_tmp = node_model.append_child(pugi::node_comment);
869 node_tmp.set_value(
"Pixel ratio");
871 node_tmp = node_model.append_child(LABEL_XML_PX);
872 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_px();
874 node_tmp = node_model.append_child(LABEL_XML_PY);
875 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_py();
877 node_tmp = node_model.append_child(pugi::node_comment);
878 node_tmp.set_value(
"Principal point");
880 node_tmp = node_model.append_child(LABEL_XML_U0);
881 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_u0();
883 node_tmp = node_model.append_child(LABEL_XML_V0);
884 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_v0();
887 node_tmp = node_model.append_child(pugi::node_comment);
888 node_tmp.set_value(
"Undistorted to distorted distortion parameter");
889 node_tmp = node_model.append_child(LABEL_XML_KUD);
890 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_kud();
893 node_tmp = node_model.append_child(pugi::node_comment);
894 node_tmp.set_value(
"Distorted to undistorted distortion parameter");
895 node_tmp = node_model.append_child(LABEL_XML_KDU);
896 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_kdu();
902 node_model = node_camera.append_child(LABEL_XML_MODEL);
904 node_tmp = node_model.append_child(pugi::node_comment);
905 node_tmp.set_value(
"Projection model type");
907 node_tmp = node_model.append_child(LABEL_XML_MODEL_TYPE);
908 node_tmp.append_child(pugi::node_pcdata).set_value(LABEL_XML_MODEL_WITH_KANNALA_BRANDT_DISTORTION);
910 node_tmp = node_model.append_child(pugi::node_comment);
911 node_tmp.set_value(
"Pixel ratio");
913 node_tmp = node_model.append_child(LABEL_XML_PX);
914 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_px();
916 node_tmp = node_model.append_child(LABEL_XML_PY);
917 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_py();
919 node_tmp = node_model.append_child(pugi::node_comment);
920 node_tmp.set_value(
"Principal point");
922 node_tmp = node_model.append_child(LABEL_XML_U0);
923 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_u0();
925 node_tmp = node_model.append_child(LABEL_XML_V0);
926 node_tmp.append_child(pugi::node_pcdata).text() = camera.get_v0();
929 std::vector<double> distortion_coefs = camera.getKannalaBrandtDistortionCoefficients();
931 if(distortion_coefs.size() != 5)
932 std::cout <<
"Make sure to have 5 distortion coefficients for Kannala-Brandt distortions." << std::endl;
934 node_tmp = node_model.append_child(pugi::node_comment);
935 node_tmp.set_value(
"Distortion coefficients");
936 node_tmp = node_model.append_child(LABEL_XML_K1);
937 distortion_coefs.size() == 0 ? node_tmp.append_child(pugi::node_pcdata).text() = 0 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[0];
938 node_tmp = node_model.append_child(LABEL_XML_K2);
939 distortion_coefs.size() <= 1 ? node_tmp.append_child(pugi::node_pcdata).text() = 0 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[1];
940 node_tmp = node_model.append_child(LABEL_XML_K3);
941 distortion_coefs.size() <= 2 ? node_tmp.append_child(pugi::node_pcdata).text() = 0 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[2];
942 node_tmp = node_model.append_child(LABEL_XML_K4);
943 distortion_coefs.size() <= 3 ? node_tmp.append_child(pugi::node_pcdata).text() = 0 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[3];
944 node_tmp = node_model.append_child(LABEL_XML_K5);
945 distortion_coefs.size() <= 4 ? node_tmp.append_child(pugi::node_pcdata).text() = 0 : node_tmp.append_child(pugi::node_pcdata).text() = distortion_coefs[4];
958 pugi::xml_node find_additional_info(
const pugi::xml_node &node_)
962 for (pugi::xml_node node = node_.first_child(); node; node = node.next_sibling()) {
963 if (node.type() != pugi::node_element) {
967 if (
SEQUENCE_OK != str2xmlcode(node.name(), prop)) {
968 prop = CODE_XML_OTHER;
971 if (prop == CODE_XML_ADDITIONAL_INFO) {
977 return pugi::xml_node();
989 vpXmlCodeType val_int = CODE_XML_BAD;
992 if (!strcmp(str, LABEL_XML_CAMERA)) {
993 val_int = CODE_XML_CAMERA;
994 }
else if (!strcmp(str, LABEL_XML_CAMERA_NAME)) {
995 val_int = CODE_XML_CAMERA_NAME;
996 }
else if (!strcmp(str, LABEL_XML_MODEL)) {
997 val_int = CODE_XML_MODEL;
998 }
else if (!strcmp(str, LABEL_XML_MODEL_TYPE)) {
999 val_int = CODE_XML_MODEL_TYPE;
1000 }
else if (!strcmp(str, LABEL_XML_WIDTH)) {
1001 val_int = CODE_XML_WIDTH;
1002 }
else if (!strcmp(str, LABEL_XML_HEIGHT)) {
1003 val_int = CODE_XML_HEIGHT;
1004 }
else if (!strcmp(str, LABEL_XML_SUBSAMPLING_WIDTH)) {
1005 val_int = CODE_XML_SUBSAMPLING_WIDTH;
1006 }
else if (!strcmp(str, LABEL_XML_SUBSAMPLING_HEIGHT)) {
1007 val_int = CODE_XML_SUBSAMPLING_HEIGHT;
1008 }
else if (!strcmp(str, LABEL_XML_FULL_WIDTH)) {
1009 val_int = CODE_XML_FULL_WIDTH;
1010 }
else if (!strcmp(str, LABEL_XML_FULL_HEIGHT)) {
1011 val_int = CODE_XML_FULL_HEIGHT;
1012 }
else if (!strcmp(str, LABEL_XML_U0)) {
1013 val_int = CODE_XML_U0;
1014 }
else if (!strcmp(str, LABEL_XML_V0)) {
1015 val_int = CODE_XML_V0;
1016 }
else if (!strcmp(str, LABEL_XML_PX)) {
1017 val_int = CODE_XML_PX;
1018 }
else if (!strcmp(str, LABEL_XML_PY)) {
1019 val_int = CODE_XML_PY;
1020 }
else if (!strcmp(str, LABEL_XML_KUD)) {
1021 val_int = CODE_XML_KUD;
1022 }
else if (!strcmp(str, LABEL_XML_KDU)) {
1023 val_int = CODE_XML_KDU;
1024 }
else if (!strcmp(str, LABEL_XML_K1)) {
1025 val_int = CODE_XML_K1;
1026 }
else if (!strcmp(str, LABEL_XML_K2)) {
1027 val_int = CODE_XML_K2;
1028 }
else if (!strcmp(str, LABEL_XML_K3)) {
1029 val_int = CODE_XML_K3;
1030 }
else if (!strcmp(str, LABEL_XML_K4)) {
1031 val_int = CODE_XML_K4;
1032 }
else if (!strcmp(str, LABEL_XML_K5)) {
1033 val_int = CODE_XML_K5;
1034 }
else if (!strcmp(str, LABEL_XML_ADDITIONAL_INFO)) {
1035 val_int = CODE_XML_ADDITIONAL_INFO;
1037 val_int = CODE_XML_OTHER;
1046 unsigned int getHeight()
const {
return image_height; }
1049 unsigned int getWidth()
const {
return image_width; }
1051 void setCameraName(
const std::string &name) { camera_name = name; }
1052 void setHeight(
unsigned int height) { image_height = height; }
1055 void setWidth(
unsigned int width) { image_width = width; }
1059 std::string camera_name;
1060 unsigned int image_width;
1061 unsigned int image_height;
1062 unsigned int subsampling_width;
1063 unsigned int subsampling_height;
1064 unsigned int full_width;
1065 unsigned int full_height;
1069 static const int allowedPixelDiffOnImageSize = 15;
1071 #endif // DOXYGEN_SHOULD_SKIP_THIS 1098 unsigned int im_width,
unsigned int im_height)
1100 return m_impl->parse(cam, filename, cam_name, projModel, im_width, im_height);
1147 unsigned int im_width,
unsigned int im_height,
1148 const std::string &additionalInfo)
1150 return m_impl->save(cam, filename, cam_name, im_width, im_height, additionalInfo);
1155 return m_impl->getCameraName();
1160 return m_impl->getCameraParameters();
1165 return m_impl->getHeight();
1170 return m_impl->getSubsampling_width();
1175 return m_impl->getSubsampling_height();
1180 return m_impl->getWidth();
1185 m_impl->setCameraName(name);
1190 m_impl->setHeight(height);
1195 m_impl->setSubsampling_width(subsampling);
1200 m_impl->setSubsampling_height(subsampling);
1205 m_impl->setWidth(width);
unsigned int getHeight() const
vpCameraParameters getCameraParameters() const
void setHeight(unsigned int height)
void setWidth(unsigned int width)
void setCameraName(const std::string &name)
void initProjWithKannalaBrandtDistortion(double px, double py, double u0, double v0, const std::vector< double > &distortion_coefficients)
void setSubsampling_height(unsigned int subsampling)
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
vpCameraParametersProjType
unsigned int getSubsampling_height() const
Generic class defining intrinsic camera parameters.
unsigned int getSubsampling_width() 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)
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
vpCameraParametersProjType get_projModel() const
unsigned int getWidth() const
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="")
std::string getCameraName() const
void setSubsampling_width(unsigned int subsampling)