ice_conversions.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package VisionX::ArmarXObjects::armem_images
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #include "ice_conversions.h"
24 
27 
28 namespace visionx::armem::camera
29 {
30  void
31  fromIce(visionx::arondto::CameraParameters& aron, const visionx::CameraParameters& ice)
32  {
33  // TODO: What if other calib than IVT? (e.g. OpenCV uses 6 radial and 2 tangential distortions)
34 
35  aron.width = ice.width;
36  aron.height = ice.height;
37  ARMARX_CHECK(ice.distortion.size() ==
38  4); // Camera calibration from IVT = {radial d1 + d2, tangential d3 + d4}
39  aron.radialDistortion = std::vector<float>{ice.distortion[0], ice.distortion[1]};
40  aron.tangentialDistortion = std::vector<float>{ice.distortion[2], ice.distortion[3]};
41  armarx::core::eigen::fromIce(aron.focalLength, ice.focalLength);
42  armarx::core::eigen::fromIce(aron.principalPoint, ice.principalPoint);
43  armarx::core::eigen::fromIce(aron.translation, ice.translation);
44  armarx::core::eigen::fromIce(aron.rotation, ice.rotation);
45  }
46 
47  void
48  toIce(const visionx::arondto::CameraParameters& aron, visionx::CameraParameters& ice)
49  {
50  // TODO: What if other calib than IVT? (e.g. OpenCV uses 6 radial and 2 tangential distortions)
51 
52  ice.width = aron.width;
53  ice.height = aron.height;
54  ice.distortion = std::vector<float>{aron.radialDistortion[0],
55  aron.radialDistortion[1],
56  aron.tangentialDistortion[0],
57  aron.tangentialDistortion[1]};
58  armarx::core::eigen::toIce(aron.focalLength, ice.focalLength);
59  armarx::core::eigen::toIce(aron.principalPoint, ice.principalPoint);
60  armarx::core::eigen::toIce(aron.translation, ice.translation);
61  armarx::core::eigen::toIce(aron.rotation, ice.rotation);
62  }
63 
64  void
65  fromIce(visionx::arondto::MonocularCameraCalibration& aron,
66  const visionx::MonocularCalibration& ice)
67  {
68  fromIce(aron.cameraParam, ice.cameraParam);
69  }
70 
71  void
72  toIce(const visionx::arondto::MonocularCameraCalibration& aron,
73  visionx::MonocularCalibration& ice)
74  {
75  toIce(aron.cameraParam, ice.cameraParam);
76  }
77 
78  void
79  fromIce(visionx::arondto::StereoCameraCalibration& aron, const visionx::StereoCalibration& ice)
80  {
81  fromIce(aron.calibrationLeft, ice.calibrationLeft);
82  fromIce(aron.calibrationRight, ice.calibrationRight);
83  armarx::core::eigen::fromIce(aron.rectificationHomographyLeft,
84  ice.rectificationHomographyLeft);
85  armarx::core::eigen::fromIce(aron.rectificationHomographyRight,
86  ice.rectificationHomographyRight);
87  }
88 
89  void
90  toIce(const visionx::arondto::StereoCameraCalibration& aron, visionx::StereoCalibration& ice)
91  {
92  toIce(aron.calibrationLeft, ice.calibrationLeft);
93  toIce(aron.calibrationRight, ice.calibrationRight);
94  armarx::core::eigen::toIce(aron.rectificationHomographyLeft,
95  ice.rectificationHomographyLeft);
96  armarx::core::eigen::toIce(aron.rectificationHomographyRight,
97  ice.rectificationHomographyRight);
98  }
99 } // namespace visionx::armem::camera
visionx::armem::camera::toIce
void toIce(const visionx::arondto::CameraParameters &aron, visionx::CameraParameters &ice)
Definition: ice_conversions.cpp:48
ice_conversions.h
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
visionx::armem::camera
Definition: constants.cpp:3
visionx::armem::camera::fromIce
void fromIce(visionx::arondto::CameraParameters &aron, const visionx::CameraParameters &ice)
Definition: ice_conversions.cpp:31
armarx::core::eigen::fromIce
void fromIce(Eigen::Vector2f &e, const Ice::FloatSeq &ice)
Definition: ice_conversions.cpp:10
armarx::core::eigen::toIce
void toIce(const Eigen::Vector2f &e, Ice::FloatSeq &ice)
Definition: ice_conversions.cpp:17
ice_conversions.h