32 #include <Geometry/ProjectionParametersSphericalFast.hh>
33 #include <Base/Common/SharedPtr.hh>
34 #include <Base/Math/Random.hh>
39 int main(
int argc,
char *argv[]) {
42 const unsigned width = 640, height = 480;
47 Rtmp.
SetXYZ(1.0, 2.15, -0.7);
53 vector<double> coeffsDist(5, 0.0);
55 coeffsDist[1] = -0.025;
62 cout <<
"projection " << *proj << endl;
65 cout <<
"testing clone and = operator " << endl;
69 BIASERR(
"clone operator does not work" << endl);
72 cout <<
"clone " << *proj2 << endl;
75 BIASERR(
"= operator does not work" << endl);
78 cout <<
"= " << proj3 << endl;
84 const string filename =
"TestProjectionParametersSimple.xml";
85 if (proj->
XMLWrite(filename)!=0) { BIASABORT; }
87 if (proj6.
XMLRead(filename)!=0) { BIASABORT; }
88 cout <<
"proj " << *proj << endl;
89 cout <<
"proj6 " << proj6 << endl;
91 BIASERR(
"xml input/output does not work" << endl);
99 cout <<
"proj " << *proj << endl;
100 cout <<
"proj5 " << proj5 << endl;
102 BIASERR(
"xml streaming does not work" << endl);
107 cout <<
"proj used for project-unproject test " << *proj << endl;
111 cout <<
"p3d " << p3dtmp <<
" p2d " << p2dtmp << endl;
114 double lambda = (p3dtmp[0]-pos[0])/dir[0];
115 double lambda2 = (p3dtmp[1]-pos[1])/dir[1];
116 double lambda3 = (p3dtmp[2]-pos[2])/dir[2];
117 cout <<
"lambda " << lambda <<
" " << lambda2 <<
" " << lambda3 << endl;
118 cout <<
"unprojected " << pos <<
" " << dir <<
" point " << pos + lambda3 * dir << endl;
127 const int num_tries = 1e4;
128 double minAcc = 1e-4;
129 for (
int n=0; n<num_tries; n++){
145 if(p2d[0] == 0 && p2d[1] == 0 && p2d[2] == 0){
151 double error = (ref-p3d).NormL2();
153 cout <<
"high error orig : " << p3d <<
" proj/unproj " << ref <<
" error " << error << endl;
159 if(p2d[0] == 0 && p2d[1] == 0 && p2d[2] == 0){
162 double depth = (p3d-C).NormL2();
167 double error = (ref-p3d).NormL2();
169 cout <<
"high error in second part orig " << p3d <<
" proj/unproj " << ref <<
" error " << error << endl;
int XMLReadFromString(const std::string &str)
reconstruct xml tree from string
void GetEuclidean(Vector3< HOMGPOINT3D_TYPE > &dest) const
calculate affine coordinates of this and write them to dest affine coordinates are projective coordin...
void Set(const T *pv)
copy the array of vectorsize beginning at *T to this->data_
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
void SetXYZ(ROTATION_MATRIX_TYPE PhiX, ROTATION_MATRIX_TYPE PhiY, ROTATION_MATRIX_TYPE PhiZ)
Set Euler angles (in rad) in order XYZ.
int XMLRead(const std::string &Filename)
derived classes must implement the function XMLIn which is called by this function XMLRead to read ev...
virtual void SetR(const BIAS::RMatrix &R)
Set orientation from rotation matrix R.
int XMLWriteToString(std::string &str, std::string encoding="UTF-8") const
serialize xml tree to string
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
virtual HomgPoint2D Project(const HomgPoint3D &X, bool IgnoreDistortion=false) const
calculates the projection of a point in the world coordinate system to a pixel in the image plane of ...
int XMLWrite(const std::string &Filename, int CompressionLevel=0, bool AutoAddCompressionSuffix=true, std::string encoding="UTF-8") const
call this to add the class to a new xml tree and write it to the file Filename.
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_...
Implements a 3D rotation matrix.
virtual void SetC(const BIAS::Vector3< double > &C)
Set projection center.
class for producing random numbers from different distributions
double NormL2() const
the L2 norm sqrt(a^2 + b^2 + c^2)
class BIASGeometryBase_EXPORT HomgPoint3D