25 #include "Geometry/ProjectionParametersIO.hh"
27 #include <Base/Image/ImageAttributes.hh>
28 #include <MathAlgo/Interpolator.hh>
30 #include <Geometry/RMatrix.hh>
31 #include <Base/Common/FileHandling.hh>
80 std::ifstream ifs(filename.c_str());
81 return ReadFromBBCStream(ifs, cd, addppx, addppy, silent);
91 int result = exifdata.
Read(filename);
92 if (result!=0)
return result;
104 if (result<0)
return result;
106 if (result<0)
return result;
108 int width=0, height=0;
110 if (result<0)
return result;
117 if (result<0)
return result;
120 if (result<0)
return result;
131 const double& addppx,
132 const double& addppy,
135 unsigned int BBCWidth=0, BBCHeight=0;
137 double BBCPxSizeX=0, BBCPxSizeY=0, BBCCxShift=0,
138 BBCCyShift=0,BBCFocalLength=0,BBCk3=0,BBCk5=0,BBCCircleRadius=0;
139 bool isSpherical =
false;
144 while (ifs.getline(linebuf,200)) {
149 if (key ==
"Ident") iss >> BBCIdent;
150 else if (key ==
"CVec") iss >> BBCC[0]>> BBCC[1]>> BBCC[2];
151 else if (key ==
"AVec") iss >> BBCA[0]>> BBCA[1]>> BBCA[2];
152 else if (key ==
"UpVec") iss >> BBCUp[0]>> BBCUp[1]>> BBCUp[2];
153 else if (key ==
"Width") iss >> BBCWidth;
154 else if (key ==
"Height") iss >> BBCHeight;
155 else if (key ==
"PixelSizeX") iss >> BBCPxSizeX;
156 else if (key ==
"PixelSizeY") iss >> BBCPxSizeY;
157 else if (key ==
"CenterPointShiftX") iss >> BBCCxShift;
158 else if (key ==
"CenterPointShiftY") iss >> BBCCyShift;
159 else if (key ==
"FocalLength") iss >> BBCFocalLength;
160 else if (key ==
"RadDistK3") iss >> BBCk3;
161 else if (key ==
"RadDistK5") iss >> BBCk5;
162 else if (key ==
"CircleRadius") iss >> BBCCircleRadius;
163 else if (key.find(
"o_SphericalCamera")!=string::npos) isSpherical =
true;
164 if (key ==
"}")
break;
170 cout<<
"BBC parameters are spherical"<<endl;
172 cout<<
"BBC parameters are perspective"<<endl;
173 cout <<
"BBC CVec: "<<BBCC<<endl;
174 cout <<
"BBC AVec: "<<BBCA<<
" with norm="<< BBCA.
NormL2()<<endl;
175 cout <<
"BBC UpVec: "<<BBCUp<<
" with norm="<< BBCUp.
NormL2()<<endl;
176 cout <<
"BBC Width: "<<BBCWidth<<endl;
177 cout <<
"BBC Height: "<<BBCHeight<<endl;
178 cout <<
"BBC PixelSizeX: "<<BBCPxSizeX<<endl;
179 cout <<
"BBC PixelSizeY: "<<BBCPxSizeY<<endl;
180 cout <<
"BBC CenterPointShiftX: "<<BBCCxShift<<endl;
181 cout <<
"BBC CenterPointShiftY: "<<BBCCyShift<<endl;
182 cout <<
"BBC FocalLength: "<<BBCFocalLength<<endl;
183 cout <<
"BBC Radials "<<BBCk3<<
" "<<BBCk5<<endl;
184 cout <<
"CircleRadius"<< BBCCircleRadius<<endl;
191 K[0][0] = BBCFocalLength / BBCPxSizeX;
192 K[1][1] = BBCFocalLength / BBCPxSizeY;
196 K[0][2] = double(BBCWidth-1)/2.0 + (BBCCxShift+addppx) / BBCPxSizeX;
197 K[1][2] = double(BBCHeight-1)/2.0 + (BBCCyShift+addppy) / BBCPxSizeY;
214 for (
unsigned int i=0;i<3;i++){
223 ss<<
"FreeD_Camera_ID"<<BBCIdent;
231 BIASERR(
"Sensor-data incomplete. Camera ID=" << cd.
CamID_
232 <<
", Image Width= " << cd.
width_
233 <<
", Image Height= " << cd.
height_);
249 BIASASSERT(BBCPxSizeX == BBCPxSizeY);
250 BIASASSERT(K[0][0]>0.0);
252 cd.
radius_ = floor(BBCCircleRadius / BBCPxSizeX);
256 for (
unsigned int r=1; r<=cd.
radius_; r++) {
258 double realTheta = asin(
double(r) / K[0][0]) / BBCk3;
259 cout<<
"ideal theta = "<< idealTheta<<
" real="<<realTheta <<endl;
279 cd.
kc1Def_ = -1.0 * BBCk3 * BBCFocalLength * BBCFocalLength;
280 cd.
kc2Def_ = -1.0 * BBCk5 * BBCFocalLength * BBCFocalLength *
281 BBCFocalLength * BBCFocalLength;
303 const int w,
const int h,
331 #ifdef BIAS_HAVE_XML2
334 const std::vector<CameraData>& vcd,
335 const std::vector<SensorData>& vsd) {
338 xmlNodePtr rootNode, childNode1, childNode2, childNode3;
339 rootNode = myXML.
create(
"rig");
340 myXML.
addAttribute(rootNode,
"version", std::string(
"1.0") );
341 for (
unsigned int i=0; i<vcd.size(); i++) {
342 childNode1 = myXML.
addChildNode(rootNode,
"cameraDescription");
343 AddCameraDataToRig(myXML, childNode1, vcd[i]);
344 childNode2 = myXML.
addChildNode(childNode1,
"poseInRig");
345 myXML.
addComment(childNode2,
"Pitch, Yaw and Roll are the Rotation_ angles of the camera around the rigs X, Y and Z Axes relative to the rig Rotation_. The Rotation_s are applied in the order XYZ or PYR with fixed axes.");
347 myXML.
addContent(childNode3, vcd[i].PoseInRigCenter_[0]);
349 myXML.
addContent(childNode3, vcd[i].PoseInRigCenter_[1]);
351 myXML.
addContent(childNode3, vcd[i].PoseInRigCenter_[2]);
352 myXML.
addComment(childNode2,
"Rotation_ direction: from rig reference system to camera frame.");
354 myXML.
addContent(childNode3, vcd[i].PoseInRigYaw_);
356 myXML.
addContent(childNode3, vcd[i].PoseInRigPitch_);
358 myXML.
addContent(childNode3, vcd[i].PoseInRigRoll_);
361 for (
unsigned int i=0; i<vsd.size(); i++) {
362 childNode1 = myXML.
addChildNode(rootNode,
"sensorDescription");
363 childNode2 = myXML.
addChildNode(childNode1,
"poseInRig");
365 myXML.
addContent(childNode3, vsd[i].PoseInRigCenter_[0]);
367 myXML.
addContent(childNode3, vsd[i].PoseInRigCenter_[1]);
369 myXML.
addContent(childNode3, vsd[i].PoseInRigCenter_[2]);
370 myXML.
addComment(childNode2,
"Rotation_ direction: from rig reference system to sensor frame.");
373 myXML.
addContent(childNode3, vsd[i].PoseInRigPitch_);
375 myXML.
addContent(childNode3, vsd[i].PoseInRigYaw_);
377 myXML.
addContent(childNode3, vsd[i].PoseInRigRoll_);
379 myXML.
write(filename);
385 std::vector<CameraData>& vcd,
387 std::vector<SensorData> vsd;
388 int ret = ReadRigData(filename,vcd,vsd);
391 BIASERR(
"The data file contained sensor data, use ReadRigData"
392 <<
"with vector<SensorData> to get it.");
400 std::vector<CameraData>& vcd,
401 std::vector<SensorData>& vsd,
408 xmlNodePtr rootNode, childNode1, childNode2;
410 rootNode = myXML.
read(filename);
411 if (rootNode==NULL) {
413 BIASERR(
"Rig-Parameter-File not found or parse error: " << filename <<
" cwd="<<
FileHandling::GetCwd() );
423 BIASERR(
"Root node has to be \"rig\" or \"camera\"");
429 return ReadCameraData(filename, vcd[0]);
438 if (vers!=RIG_PARAMETER_CURRENT_XML_VERSION) {
439 BIASWARN(
"Rig-Parameter File Version (" << vers <<
")is Deprecated, "
440 <<
"current version is " << RIG_PARAMETER_CURRENT_XML_VERSION);
442 ReadRigDataV0_8(filename, vcd);
450 if (childNode1 == NULL) {
452 BIASERR(
"No CameraDescriptions in Rig, empty Rig???");
462 if (myXML.
getNodeName(childNode1)==
"cameraDescription") {
464 childNode2 = myXML.
getChild(childNode1,
"camera");
465 if (childNode2 == NULL) {
467 BIASERR(
"\"CameraDescription\" without a \"Camera\" is not possible.");
471 if (ReadCameraData(myXML, childNode2, cd)<0)
return -1;
473 childNode2 = myXML.
getChild(childNode1,
"poseInRig");
474 if (childNode2 == NULL) {
476 BIASERR(
"\"cameraDescription\" without a \"poseInRig\" is not possible.");
497 if (myXML.
getNodeName(childNode1)==
"sensorDescription") {
498 InitializeSensor(sd);
499 childNode2 = myXML.
getChild(childNode1,
"poseInRig");
500 if (childNode2 == NULL) {
502 BIASERR(
"\"sensorDescription\" without a \"poseInRig\" is not possible.");
523 }
while (childNode1!=NULL);
526 if (vcd.size()==0)
return -1;
533 std::vector<CameraData>& vcd,
537 xmlNodePtr rootNode, childNode1, childNode2;
539 rootNode = myXML.
read(filename);
540 if (rootNode==NULL) {
542 BIASERR(
"Rig-Parameter-File not found or parse error: " << filename);
549 if (childNode1 == NULL) {
551 BIASERR(
"No CameraDescriptions in Rig, empty Rig???");
559 if (myXML.
getNodeName(childNode1)==
"CameraDescription") {
561 childNode2 = myXML.
getChild(childNode1,
"Camera");
562 if (childNode2 == NULL) {
564 BIASERR(
"\"CameraDescription\" without a \"Camera\" is not possible.");
568 if (ReadCameraData(myXML, childNode2, cd)<0)
return -1;
570 childNode2 = myXML.
getChild(childNode1,
"PoseInRig");
571 if (childNode2 == NULL) {
573 BIASERR(
"\"CameraDescription\" without a \"PoseInRig\" is not possible.");
594 }
while (childNode1!=NULL);
596 if (vcd.size()==0)
return -1;
607 rootNode = myXML.
create(
"camera");
609 CAMERA_PARAMETER_CURRENT_XML_VERSION);
610 AddCameraDataToNode(myXML, rootNode, cd);
611 myXML.
write(Filename);
618 xmlNodePtr &cameraDataNode,
621 xmlNodePtr childNode;
622 childNode = myXML.
addChildNode(cameraDataNode,
"camera");
624 std::string(
"2.0") );
625 AddCameraDataToNode(myXML, childNode, cd);
632 xmlNodePtr &rootNode,
636 xmlNodePtr childNode2, childNode3, childNode4;
637 myXML.
addComment(rootNode,
"\"Model\" is an arbitrary camera name.\n \"SerialID\" is i.e. the camera firewire-bus ID.\n \"ImageWidth\" and \"ImageHeight\" are in pixel.\n \"CellSizeX\" is the size of one CCD-cell in meter.\n \"AspectRatio\" is CellsizeX/CellSizeY (same as FocalLengthY/FocalLengthX).");
645 myXML.
addComment(rootNode,
"\"Model\" is an arbitrary name.\n \"Type\" can be either \"Spherical\" or \"Perspective\"");
650 LensType=
"Spherical";
652 LensType=
"Perspective";
656 childNode3 = myXML.
addChildNode(childNode2,
"AngleCalib");
657 myXML.
addComment(childNode3,
"Measurement points of angle calibration curve.\n \"AngRay\" is the angle of the viewing ray, \"AngDeformed\" is the Angle deformed by the camera.\n The maximium \"AngRay\" is the cameras FoV.");
665 childNode3 = myXML.
addChildNode(childNode2,
"AngleCalibPoly");
666 myXML.
addComment(childNode3,
"Polynome coefficients (polynomial degree 4 CN*x^N) from matlab calibration toolbox, see: http://asl.epfl.ch/~scaramuz/research/Davide_Scaramuzza_files/Research/OcamCalib_Tutorial.htm");
675 childNode3 = myXML.
addChildNode(childNode2,
"PerspectiveCalib");
676 myXML.
addComment(childNode3,
"\"FocalLength\" is FocalLengthX in meters, if you want to give it in pixel set \"CellSizeX\"=1.\n\"k1\" and \"k2\" are radial distortion; \"p1\", \"p2\" are tangential distortion.\n Camera calibration constants coming from the matlab toolbox 'http://www.vision.caltech.edu/bouguetj/calib_doc/'.\n Distortion is calculated as x'=x*(1+k1*r^2+k2*r^4)+2*p1*x*y+p2*(r^2+2*x^2) and y'=y*(1+k1*r^2+k2*r^4)+2*p1*(r^2+2*y^2)+2*p2*x*y with r^2=(x^2+y^2).");
688 childNode4 = myXML.
addChildNode(childNode3,
"ZoomStep");
700 childNode3 = myXML.
addChildNode(childNode2,
"VignetteCalib");
702 myXML.
addComment(childNode3,
"The measurements for vignette calibration relate the angle of the viewing ray to an absorbtion factor for the corresponding image pixels.");
709 myXML.
addComment(childNode3,
"The measurements for vignette calibration relate the distance of a pixel from the image principal point to an absorbtion factor for the corresponding image pixels.");
717 myXML.
addComment(rootNode,
"The \"PrincipalPoint\" is given as a fraction of \"ImageWidth\"/\"ImageHeight\" with (0.5,0.5) is the image center.");
718 childNode2 = myXML.
addChildNode(rootNode,
"PrincipalPoint");
722 myXML.
addComment(childNode2,
"The \"SphereRadius\" is given as a fraction of \"ImageWidth\".");
736 rootNode = myXML.
read(Filename);
737 if (rootNode==NULL) {
739 BIASERR(
"Camera-Parameter-File not found or parse error: " << Filename);
747 BIASERR(
"Root node has to be \"camera\"");
751 ReadCameraData (myXML, rootNode, cd);
758 xmlNodePtr &cameraNode,
770 if (vers!=CAMERA_PARAMETER_CURRENT_XML_VERSION) {
771 BIASWARN(
"Camera-Parameter Version (" << vers <<
") is Deprecated, "
772 <<
"current version is " << CAMERA_PARAMETER_CURRENT_XML_VERSION);
774 ReadCameraDataV0_8(myXML, cameraNode, cd);
778 ReadCameraDataV1_0(myXML, cameraNode, cd);
786 xmlNodePtr childNode2, childNode3, childNode4;
788 childNode2 = myXML.
getChild(cameraNode,
"Sensor");
789 if (childNode2!=NULL) {
796 BIASERR(
"Sensor-data incomplete. Camera Model=" << cd.
CamModel_
797 <<
", Camera Serial=" << cd.
CamID_
798 <<
", Image Width=" << cd.
width_
799 <<
", Image Height" << cd.
height_);
814 BIASERR(
"Node \"Sensor\" missing.");
819 childNode2 = myXML.
getChild(cameraNode,
"Lens");
820 if (childNode2==NULL) {
822 BIASERR(
"Node \"Lens\" missing.");
830 if (LensType!=
"Spherical" && LensType!=
"Perspective") {
832 BIASERR(
"Unknown Lens-Type, has to be \"Spherical\" or \"Perspective\".");
836 if (LensType==
"Spherical") {
839 childNode3 = myXML.
getChild(childNode2,
"AngleCalib");
840 if (childNode3!=NULL) {
842 if (childNode4 == NULL) {
844 BIASERR(
"No angle calibration measurement points.");
858 }
while (childNode4!=NULL);
861 childNode3 = myXML.
getChild(childNode2,
"AngleCalibPoly");
862 if (childNode3==NULL && cd.
AngleCorrX_.size()==0) {
864 BIASERR(
"One on the nodes \"AngleCalib\" or \"AngleCalibPoly\"" <<
877 InitAngleCorrFromPoly_(cd);
881 if (LensType==
"Perspective") {
884 childNode3 = myXML.
getChild(childNode2,
"PerspectiveCalib");
885 if (childNode3 != NULL) {
887 if (childNode4 != NULL) {
918 }
while (childNode4!=NULL);
931 childNode3 = myXML.
getChild(childNode2,
"VignetteCalib");
932 if (childNode3 != NULL) {
934 if (childNode4 != NULL) {
948 }
while (childNode4!=NULL);
952 childNode2 = myXML.
getChild(cameraNode,
"PrincipalPoint");
953 if (childNode2 != NULL) {
965 BIASWARN(endl<<endl<<endl<<
"The SphereRadius field in your camera"
966 <<
" parameter file is redundant and must be consistent with"
967 <<
" the maximum cam angle. Your value of SphereRadius "
968 <<
" will be ignored and computed"<<endl<<endl<<endl);
991 xmlNodePtr &cameraNode,
999 xmlNodePtr childNode2, childNode3, childNode4, childNode5, childNode6;
1001 childNode2 = myXML.
getChild(cameraNode,
"id");
1005 BIASERR(
"Sensor-data incomplete. Camera ID must not be 0:" << cd.
CamID_);
1010 childNode2 = myXML.
getChild(cameraNode,
"sensor");
1011 if (childNode2!=NULL) {
1012 childNode3 = myXML.
getChild(childNode2,
"numberOfPixels");
1013 childNode4 = myXML.
getChild(childNode3,
"x");
1015 childNode4 = myXML.
getChild(childNode3,
"y");
1019 BIASERR(
"Sensor-data incomplete. Camera ID=" << cd.
CamID_
1020 <<
", Image Width= " << cd.
width_
1021 <<
", Image Height= " << cd.
height_);
1026 childNode3 = myXML.
getChild(childNode2,
"pixelSpacing");
1027 childNode4 = myXML.
getChild(childNode3,
"x");
1029 childNode4 = myXML.
getChild(childNode3,
"y");
1036 childNode3 = myXML.
getChild(childNode2,
"principalPoint");
1037 if (childNode3 != NULL) {
1038 childNode4 = myXML.
getChild(childNode3,
"x");
1040 childNode4 = myXML.
getChild(childNode3,
"y");
1052 BIASERR(
"Node \"sensor\" missing.");
1057 childNode2 = myXML.
getChild(cameraNode,
"lens");
1058 if (childNode2!=NULL) {
1062 childNode2 = myXML.
getChild(cameraNode,
"zoomLens");
1063 if (childNode2!=NULL) {
1067 childNode2 = myXML.
getChild(cameraNode,
"sphericalLens");
1068 if (childNode2!=NULL) {
1073 BIASERR(
"Camera has no lens-, zoomLens- or sphericalLens-Tag");
1084 childNode3 = myXML.
getChild(childNode2,
"angleCalibration");
1085 if (childNode3==NULL) {
1087 BIASERR(
"Node \"angleCalibration\" missing.");
1092 if (childNode4 == NULL) {
1094 BIASERR(
"No angle calibration measurement points.");
1101 childNode5 = myXML.
getChild(childNode4,
"angleRay");
1103 childNode5 = myXML.
getChild(childNode4,
"angleDeformed");
1108 }
while (childNode4!=NULL);
1111 childNode3 = myXML.
getChild(childNode2,
"vignetteCalibration");
1112 if (childNode3 != NULL) {
1114 if (childNode4 != NULL) {
1118 childNode5 = myXML.
getChild(childNode4,
"angleRay");
1120 childNode5 = myXML.
getChild(childNode4,
"factor");
1125 }
while (childNode4!=NULL);
1129 childNode3 = myXML.
getChild(childNode2,
"sphereRadius");
1131 if (childNode3==NULL) {
1133 BIASERR(
"Sphere radius missing!");
1140 childNode3 = myXML.
getChild(childNode2,
"focalLength");
1144 childNode3 = myXML.
getChild(childNode2,
"distortion");
1145 childNode4 = myXML.
getChild(childNode3,
"radial");
1146 childNode5 = myXML.
getChild(childNode4,
"k1");
1148 childNode5 = myXML.
getChild(childNode4,
"k2");
1150 childNode4 = myXML.
getChild(childNode3,
"tangential");
1151 childNode5 = myXML.
getChild(childNode4,
"p1");
1153 childNode5 = myXML.
getChild(childNode4,
"p2");
1157 if (childNode3 != NULL) {
1161 childNode4 = myXML.
getChild(childNode3,
"zoom");
1163 childNode4=myXML.
getChild(childNode3,
"focalLength");
1167 childNode4=myXML.
getChild(childNode3,
"distortion");
1168 childNode5=myXML.
getChild(childNode4,
"radial");
1169 childNode6=myXML.
getChild(childNode5,
"k1");
1171 childNode6=myXML.
getChild(childNode5,
"k2");
1173 childNode5=myXML.
getChild(childNode4,
"tangential");
1174 childNode6=myXML.
getChild(childNode5,
"p1");
1176 childNode6=myXML.
getChild(childNode5,
"p2");
1180 if (myXML.
getNodeName(childNode3)==
"defaultZoom") {
1182 BIASERR(
"defaultZoom is deprecated and has no effect, use different param-file version");
1186 }
while (childNode3!=NULL);
1203 xmlNodePtr &cameraNode,
1205 const bool silent) {
1209 xmlNodePtr childNode2, childNode3, childNode4;
1211 childNode2 = myXML.
getChild(cameraNode,
"Sensor");
1212 if (childNode2!=NULL) {
1219 BIASERR(
"Sensor-data incomplete. Camera Model=" << cd.
CamModel_
1220 <<
", Camera Serial=" << cd.
CamID_
1221 <<
", Image Width=" << cd.
width_
1222 <<
", Image Height" << cd.
height_);
1244 BIASERR(
"Node \"Sensor\" missing.");
1249 childNode2 = myXML.
getChild(cameraNode,
"Lens");
1250 if (childNode2==NULL) {
1252 BIASERR(
"Node \"Lens\" missing.");
1260 if (LensType!=
"Spherical" && LensType!=
"Perspective") {
1262 BIASERR(
"Unknown Lens-Type, has to be \"Spherical\" or \"Perspective\".");
1266 if (LensType==
"Spherical") {
1269 childNode3 = myXML.
getChild(childNode2,
"AngleCalib");
1270 if (childNode3==NULL) {
1272 BIASERR(
"Node \"AngleCalib\" missing.");
1277 if (childNode4 == NULL) {
1279 BIASERR(
"No angle calibration measurement points.");
1292 }
while (childNode4!=NULL);
1295 if (LensType==
"Perspective") {
1298 childNode3 = myXML.
getChild(childNode2,
"PerspectiveCalib");
1299 if (childNode3 != NULL) {
1301 if (childNode4 != NULL) {
1332 }
while (childNode4!=NULL);
1345 childNode3 = myXML.
getChild(childNode2,
"VignetteCalib");
1346 if (childNode3 != NULL) {
1348 if (childNode4 != NULL) {
1362 }
while (childNode4!=NULL);
1366 childNode2 = myXML.
getChild(cameraNode,
"PrincipalPoint");
1367 if (childNode2 != NULL) {
1388 double pix_def, ang_def, ang_pix_der, ang_opt;
1392 vector<double> vx, vy;
1393 double maxradius = 0;
1394 for (
unsigned int x=0; x<cd.
width_/2; x++) {
1399 double y = atan2(x,-pol);
1404 cout<<
"maxradius determined as "<<maxradius<<endl;
1408 ang_pix_der = vy[1]-vy[0];
1423 ip_inv.
Spline(pix_def,ang_opt);
1424 ang_def = pix_def*ang_pix_der;
1463 dp.
kc1=-0.268280770809586;
1464 dp.
kc2=0.487451704517498;
1465 dp.
kc3=-0.000762042258562;
1466 dp.
kc4=-0.001130194838780;
1471 dp.
kc1=-0.222325918868402;
1472 dp.
kc2=0.303803084817878;
1473 dp.
kc3=-0.000220828107747;
1474 dp.
kc4=-0.002379174938453;
1479 dp.
kc1=-0.230499856719837;
1480 dp.
kc2=0.632569092436950;
1481 dp.
kc3=0.000645301367934;
1482 dp.
kc4=-0.002245120579513;
1487 dp.
kc1=-0.175147739150835;
1488 dp.
kc2=0.399855896767651;
1489 dp.
kc3=0.001819727735452;
1490 dp.
kc4=-0.004642715440390;
1495 dp.
kc1=-0.199908717507440;
1496 dp.
kc2=0.735328948045900;
1497 dp.
kc3=0.001857139856879;
1498 dp.
kc4=-0.001726332328807;
1503 dp.
kc1=-0.194029932886528;
1504 dp.
kc2=1.052137931539009;
1505 dp.
kc3=0.002556010034664;
1506 dp.
kc4=-0.002664280436511;
1511 dp.
kc1=-0.222381373429422;
1512 dp.
kc2=1.627430874083972;
1513 dp.
kc3=0.001072744905158;
1514 dp.
kc4=-0.001628105221342;
1519 dp.
kc1=-0.221923278642680;
1520 dp.
kc2=1.734685282276320;
1521 dp.
kc3=0.002486050695331;
1522 dp.
kc4=-0.001291711925732;
1527 dp.
kc1=-0.224447467694984;
1528 dp.
kc2=1.863840161034580;
1529 dp.
kc3=0.003709677616807;
1530 dp.
kc4=-0.001150445035362;
1535 dp.
kc1=-0.202923793671622;
1536 dp.
kc2=1.473981778670278;
1537 dp.
kc3=0.003684677768293;
1538 dp.
kc4=-0.002550288087126;
1543 dp.
kc1=-0.217240281709651;
1544 dp.
kc2=2.140024501420107;
1545 dp.
kc3=0.001114854630183;
1546 dp.
kc4=-0.001295578479362;
1559 dp.
kc1=-0.255567875389573;
1560 dp.
kc2=1.732924024277849;
1561 dp.
kc3=0.001245946585972;
1562 dp.
kc4=-0.000594821663798;
1575 dp.
kc1=-0.332071279316112;
1576 dp.
kc2=0.944781789471998;
1577 dp.
kc3=0.000746973436601;
1578 dp.
kc4=-0.001772703465946;
1583 dp.
kc1=-0.404343435901478;
1584 dp.
kc2=0.453162060457514;
1585 dp.
kc3=-0.000861720421368;
1586 dp.
kc4=-0.001149130726447;
1591 dp.
kc1=-0.594320179301222;
1592 dp.
kc2=12.959736505367889;
1593 dp.
kc3=-0.001868658432064;
1594 dp.
kc4=-0.000676806079268;
1599 dp.
kc1=-0.823072669196453;
1600 dp.
kc2=27.510513372014003;
1601 dp.
kc3=-0.006928032867432;
1602 dp.
kc4=0.002134868203333;
1607 dp.
kc1=-1.121702159939672;
1608 dp.
kc2=36.994236469912934;
1609 dp.
kc3=-0.014620822228192;
1610 dp.
kc4=0.004860766468908;
1615 dp.
kc1=-1.473018481165970;
1616 dp.
kc2=41.598117903225528;
1617 dp.
kc3=-0.028692464501407;
1618 dp.
kc4=0.007739406251353;
1623 dp.
kc1=-1.786184809649660;
1624 dp.
kc2=109.639598242766894;
1625 dp.
kc3=-0.011555140535335;
1626 dp.
kc4=-0.002211119391028;
1734 SetData_EVID31_147094(cd);
1742 SetData_OMNITECH_ORIFL_190_3(cd);
1755 std::vector<BIAS::CameraData>& vcd) {
1757 os <<
"vector<CameraData>: " << endl;
1758 for (
unsigned int i=0; i<vcd.size(); i++) {
1759 os <<
" ----------- Camera " << i <<
"-----------" << endl;
1769 std::vector<BIAS::SensorData>& vsd) {
1771 os <<
"vector<SensorData>: " << endl;
1772 for (
unsigned int i=0; i<vsd.size(); i++) {
1773 os <<
" ----------- Sensor " << i <<
"-----------" << endl;
1785 os <<
"CamModel_ = " << cd.
CamModel_ << endl;
1786 os <<
"CamID_ = " << cd.
CamID_ << endl;
1787 os <<
"LensModel_ = " << cd.
LensModel_ << endl;
1790 os <<
"width_ = " << cd.
width_ << endl;
1791 os <<
"height_ = " << cd.
height_ << endl;
1793 os <<
"knownparams_vect_[" << i <<
"] = " << endl;
1796 os <<
" zoom = " << dp.
zoom << endl;
1797 os <<
" focallength = " << dp.
focallength << endl;
1798 os <<
" kc1 = " << dp.
kc1;
1799 os <<
", kc2 = " << dp.
kc2;
1800 os <<
", kc3 = " << dp.
kc3;
1801 os <<
", kc4 = " << dp.
kc4;
1810 os <<
"AngleCorrX_ = " ;
1811 for (
int i=0; i<(int) cd.
AngleCorrX_.size();i++) {
1815 os <<
"AngleCorrY_ = ";
1816 for (
int i=0; i<(int) cd.
AngleCorrY_.size();i++) {
1820 os <<
"IlluCorrX_ = ";
1821 for (
int i=0; i<(int) cd.
IlluCorrX_.size();i++) {
1825 os <<
"IlluCorrY_ = ";
1826 for (
int i=0; i<(int) cd.
IlluCorrY_.size();i++) {
1832 os <<
"cellSizeX_ = " << cd.
cellSizeX_ << endl;
1833 os <<
"cellSizeY_ = " << cd.
cellSizeY_ << endl;
1837 os <<
"kc1Def_ = " << cd.
kc1Def_ << endl;
1838 os <<
"kc2Def_ = " << cd.
kc2Def_ << endl;
1839 os <<
"kc3Def_ = " << cd.
kc3Def_ << endl;
1840 os <<
"kc4Def_ = " << cd.
kc4Def_ << endl;
virtual void EnforceConstraints()
Enforce orthonormality constraints and right-handed rotation with SVD.
void addAttribute(const xmlNodePtr Node, const std::string &AttributeName, bool AttributeValue)
Add an attribute to a node.
static void SetData_DummyRig(std::vector< CameraData > &vcd)
void InitSpline()
call this for restart at t= first knot point initiates recalculation of all polynom coefficients at f...
xmlNodePtr getNextChild()
Get the next child of the parent specified in the last getFirstChild() call, the class remembers the ...
int write(const std::string &Filename, bool AutoAddCompressionSuffix=true) const
Write the whole tree that was constructed in memory to disk.
static int ReadCameraData(const std::string &Filename, CameraData &cd, const bool silent=false)
Read a camera data parameter file and store the data in (*this)
xmlNodePtr read(const std::string &Filename)
Read and parse an XML file from disk, DtD validation is not yet implemented.
void addComment(const xmlNodePtr Node, const std::string &Comment)
Add comment to a node.
static int WriteCameraData(const std::string &Filename, const CameraData &cd)
Write all data to a camera data parameter file )
int GetPixelSizeXMeter(double &p)
compute pixel size in meter
xmlNodePtr getChild(const xmlNodePtr ParentNode, const std::string &ChildName)
Get a child of a Parent node by specifying the childs name, NULL is returned if the ParentNode has no...
xmlNodePtr create(const std::string &RootNodeName)
Create the base of a new XML-Tree in memory, already with a one and only root node.
void SetZero()
set all values to 0
int GetPrincipalPoint(double &x, double &y)
look up principal point
static int ReadRigDataV0_8(const std::string &filename, std::vector< CameraData > &vcd, const bool silent=false)
Reading old file versions.
static int ReadRigData(const std::string &filename, std::vector< CameraData > &vcd, const bool silent=false)
Read a rig parameter file and store the data in (*this) the Camera-, Center-, RMatrix-, and KMatrix-Vectors are reset from the file.
std::vector< double > IlluCorrY_
void SetKnotPoints(const std::vector< double > &kPnt)
set the additional knot points, if you want nonuniform interpolation.
std::vector< double > IlluCorrX_
static void InitializeSensor(SensorData &sd)
default zero initialization for a single sensor
static int SetFromKMatrix(const BIAS::KMatrix &K, const int w, const int h, CameraData &cd)
pass K and image dims to construct a simple parameter file
static int ReadFromBBCStream(std::ifstream &infile, CameraData &cd, const double &addppx=0.0, const double &addppy=0.0, const bool silent=false)
read bbc's freeD date from an open stream
static int WriteRigData(const std::string &filename, const std::vector< CameraData > &vcd, const std::vector< SensorData > &vsd=std::vector< SensorData >(0, SensorData()))
Write all data camera data and camera positions in the rig to a rig parameter file in XML-notation...
static std::string GetCwd()
Return current working directory as string.
static void SetData_EVID31_147094(CameraData &cd)
std::vector< double > AngleCorrX_
std::string getAttributeValueString(const xmlAttrPtr Attribute) const
int getAttributeValueInt(const xmlAttrPtr Attribute) const
this class interpolates a function y=f(t) between given control points (the y-values) ...
BIAS::Vector3< double > PoseInRigCenter_
void addContent(const xmlNodePtr Node, const std::string &Content)
Add content to a node.
double getNodeContentDouble(const xmlNodePtr Node) const
int GetPixelSizeYMeter(double &p)
compute pixel size in meter
void CrossProduct(const Vector3< T > &argvec, Vector3< T > &destvec) const
cross product of two vectors destvec = this x argvec
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
xmlNodePtr addChildNode(const xmlNodePtr ParentNode, const std::string &NewNodeName)
Add a child node to an incoming node with the given name.
static int ReadFromEXIF(const std::string &filename, CameraData &cd)
read jpeg EXIF header and set camera parameter
int GetHardwareName(std::string &Make, std::string &Model)
look up camera make and model
static int InitAngleCorrFromPoly_(CameraData &cd)
transform polynome coefficients from matlab toolbox (see: http://asl.epfl.ch/~scaramuz/research/David...
int Spline(double &res, double t, unsigned int k=3)
these functions do the Spline interpolation which reaches each control point.
std::vector< CPDiscreteParam > knownparams_vect_
xmlNodePtr getFirstChild(const xmlNodePtr ParentNode)
Get the first child of a given parent, or NULL for no childs.
void SetControlPoints(const std::vector< double > &cPnt1)
set the control points, which control the interpolating curve
int Read(const std::string &filename)
main entry routine to read all EXIF tags from the header of image file.
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
int GetFocalLengthXPixel(double &fp)
compute focallength in pixels
BIAS::Vector3< double > PoseInRigCenter_
xmlAttrPtr getAttributeByName(const xmlNodePtr Node, const std::string &attribute_name)
search for a specific attribute
double getAttributeValueDouble(const xmlAttrPtr Attribute) const
static int AddCameraDataToRig(XMLIO &myXML, xmlNodePtr &cameraDataNode, const CameraData &cd)
Add a camera sub-tree-structure to an allready created XML-tree and write the data from (*this) into ...
contains all atribute info and values of e.g. a file.
int GetRotationAnglesXYZ(double &PhiX, double &PhiY, double &PhiZ) const
Get Euler angles for this rotation matrix in order XYZ.
static int ReadCameraDataV1_0(XMLIO &myXML, xmlNodePtr &cameraNode, CameraData &cd, const bool silent=false)
void InitExifTags()
initialize me vector with all known EXIF tags
std::string getNodeName(const xmlNodePtr Node) const
Get the name of a given Node.
std::vector< double > AngleCorrY_
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
int getNodeContentInt(const xmlNodePtr Node) const
int GetImageDimensions(int &width, int &height)
get width and height of image
static void Initialize(CameraData &cd)
default zero initialization for a single camera
static int ReadCameraDataV0_8(XMLIO &myXML, xmlNodePtr &cameraNode, CameraData &cd, const bool silent=false)
static int ReadFromBBC(const std::string &filename, CameraData &cd, const double &addppx=0.0, const double &addppy=0.0, const bool silent=false)
read bbc's freeD date from a file
double NormL2() const
the L2 norm sqrt(a^2 + b^2 + c^2)
static void SetData_OMNITECH_ORIFL_190_3(CameraData &cd)
static int AddCameraDataToNode(XMLIO &myXML, xmlNodePtr &rootNode, const CameraData &cd)
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...