32 #include <Geometry/Triangulation.hh>
33 #include <Geometry/ProjectionParametersPerspective.hh>
34 #include <Geometry/ProjectionParametersSphericalSimple.hh>
35 #include <Base/Common/SharedPtr.hh>
48 int triangulation_result;
52 void FillTestCases(vector<struct STestData> &cases);
54 bool RunAndCheck(
const struct STestData &data);
57 int main(
int argc,
char *argv[])
60 string argv1 = argv[1];
61 if (argv1==
"silent") verbose =
false;
63 vector<struct STestData> cases;
66 for (
unsigned i=0; i<cases.size(); i++){
67 if (!RunAndCheck(cases[i])){
68 if (verbose) cout <<
"triangulation failed\n";
78 bool RunAndCheck(
const struct STestData &data)
84 data.p1, data.p2, p3d);
86 if (verbose) cout <<
"\nexpected: "<<data.p3d
87 <<
"\ngot: "<<p3d<<endl;
89 if (res != data.triangulation_result){
90 if (verbose) cout <<
"result mismatch: expected: "
91 <<data.triangulation_result<<
" got: "<<res<<
"\n";
103 double eps = numeric_limits<double>::epsilon() * 5.0;
105 if (verbose) cout <<
"result point is incorrect: got "<<p3d
106 <<
"\n expected: "<<tmp<<
"\n";
115 void FillTestCases(vector<struct STestData> &cases)
132 const int width = 640, height = 480;
133 const double phiOffs=0.0, thetaOffs=0., dPhi=0.001, dTheta=0.001;
142 struct STestData data;
148 data.p1.Set(0., 0., 1.);
149 data.p2.Set(-0.1, 0., 1.);
150 data.p3d.Set(0., 0., 10., 1.);
151 data.triangulation_result = 0;
152 cases.push_back(data);
155 data.p1.Set(0.1, 0., 1.);
156 data.p2.Set(0.0, 0., 1.);
157 data.p3d.Set(1., 0., 10., 1.);
158 data.triangulation_result = 0;
159 cases.push_back(data);
162 data.p1.Set(0.001, 0., 1.);
163 data.p2.Set(0.0, 0., 1.);
164 data.p3d.Set(1., 0., 1000., 1.);
165 data.triangulation_result = 0;
166 cases.push_back(data);
169 data.p1.Set(0.0, 0.0, 1.);
170 data.p2.Set(0.1, 0.0, 1.);
171 data.p3d.Set(0., 0., -10., 1.);
172 data.triangulation_result = TRIANG_RES_BEHIND_CAMERA1;
173 cases.push_back(data);
176 data.p1.Set(0.0, 0.0, 1.);
177 data.p2.Set(0.0, 0.0, 1.);
178 data.p3d.Set(0., 0., 1., 0.);
179 data.triangulation_result = TRIANG_RES_PARALLEL;
180 cases.push_back(data);
183 data.p1.Set(0.0, 0.1, 1.);
184 data.p2.Set(0.0, 0.0, 1.);
185 data.p3d.Set(0.5, 0., 0., 1.);
186 data.triangulation_result = 0;
187 cases.push_back(data);
190 data.p1.Set(0.1, 0.01, 1.);
191 data.p2.Set(-0.1, -0.01, 1.);
192 data.p3d.Set(0.5, 0., 4.950495049504950, 1.);
193 data.triangulation_result = 0;
194 cases.push_back(data);
197 data.proj1 = projsph1;
198 data.proj2 = projsph2;
201 data.p1.Set(M_PI/2./dTheta, 0.0, 1.);
202 data.p2.Set(M_PI/2./dTheta, 0.0, 1.);
203 data.p3d.Set(0., 0., 1., 0.);
204 data.triangulation_result = TRIANG_RES_PARALLEL;
205 cases.push_back(data);
208 data.p1.Set(M_PI/2./dTheta, 0.0, 1.);
209 data.p2.Set(3.*M_PI/4./dTheta, 0.0, 1.);
210 data.p3d.Set(0., 0., 1., 1.);
211 data.triangulation_result = 0;
212 cases.push_back(data);
215 data.p1.Set(M_PI/2./dTheta, 0.0, 1.);
216 data.p2.Set(M_PI/4./dTheta, 0.0, 1.);
217 data.p3d.Set(0., 0., -1., 1.);
218 data.triangulation_result = TRIANG_RES_BEHIND_CAMERA1;
219 cases.push_back(data);
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
T * Get(SharedPtr< T > &t)
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
pointer with reference count and automatic deletion
double NormL2() const
Return the L2 norm: sqrt(a^2 + b^2 + c^2 + d^2)
int TriangulateProjective(const ProjectionParametersBase *P1, const ProjectionParametersBase *P2, const HomgPoint2D &p1, const HomgPoint2D &p2, HomgPoint3D &point3d)
Triangulation for metric Poses (using C and R)
Class for triangulation of 3Dpoints from 2D matches. Covariance matrix (refering to an uncertainty el...
class Vector4 contains a Vector of dim.
virtual void SetQ(const BIAS::Quaternion< double > &Q)
Set orientation from unit quaternion Q.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
virtual void SetK(const KMatrix &K)
sets the internal parameters from a given KMatrix and updates the cached K and its inverse ...
virtual void SetC(const BIAS::Vector3< double > &C)
Set projection center.