32 #include <Geometry/ProjectionParametersSphericalSimple.hh>
33 #include <Base/Common/SharedPtr.hh>
34 #include <Base/Math/Random.hh>
40 const double phiOffs,
const double thetaOffs,
41 const double dPhi,
const double dTheta,
const unsigned width,
47 if (pw!=width) { BIASABORT; }
48 if (ph!=height) { BIASABORT; }
55 for (
int i=0; i<3; i++){
56 if (!
Equal(l1[i]-l2[i], 0., 1e-9)) {
57 cout << l1<<
"\n"<<l2<<
"\n"<<l1-l2<<
"\n"<<(l1-l2).NormL2()<<endl;
65 if (!
id.IsIdentity(1e-10)) {
66 cout <<
"R: "<<R<<
"\nRp: "<<Rp<<
"\nid: "<<
id<<endl; BIASABORT;
70 if (!
id.IsIdentity(1e-10)) {
71 cout <<
"R: "<<R<<
"\nRp: "<<Rp<<
"\nid: "<<
id<<endl; BIASABORT;
74 if (!
Equal((Cp-C).NormL2(), 0., 1e-13)){
75 cout <<
"C: "<<C<<
"\nCp: "<<Cp<<
"\tdiff: "<< C-Cp<<endl;
81 int main(
int argc,
char *argv[])
84 const double phiOffs = 0.7, thetaOffs = -0.3, dPhi = 0.05, dTheta = 0.025;
85 const unsigned width = 640, height = 480;
91 Rtmp.SetXYZ(1.0, 2.15, -0.7);
101 TestContent(
Get(proj2), phiOffs, thetaOffs, dPhi, dTheta, width, height, R, C);
103 TestContent(&proj3, phiOffs, thetaOffs, dPhi, dTheta, width, height, R, C);
105 TestContent(&proj4, phiOffs, thetaOffs, dPhi, dTheta, width, height, R, C);
115 TestContent(&proj5, phiOffs, thetaOffs, dPhi, dTheta, width, height, R, C);
116 const string filename =
"TestProjectionParametersSimple.xml";
117 if (proj->
XMLWrite(filename)!=0) { BIASABORT; }
119 if (proj6.
XMLRead(filename)!=0) { BIASABORT; }
120 TestContent(&proj6, phiOffs, thetaOffs, dPhi, dTheta, width, height, R, C);
129 const int num_tries = 100000;
130 for (
int n=0; n<num_tries; n++){
147 for (
int i=0; i<3; i++){
148 if (!
Equal(ref[i]-p3d[i], 0., 1e-13)) {
149 cout <<
"orig: "<<p3d<<
"\nproj/unproj: "<<ref<<endl
150 <<i<<
"\t"<<ref[i]-p3d[i]<<endl;
157 double depth = (p3d-C).NormL2();
162 for (
int i=0; i<3; i++){
163 if (!
Equal(ref[i]-p3d[i], 0., 1e-13)) {
164 cout <<
"orig[i] : "<<setprecision(20)<<p3d[i]
165 <<
"\nproj/unproj: "<<setprecision(20)<<ref[i]<<endl;
166 cout <<
"orig : "<<p3d
167 <<
"\nproj/unproj: "<<ref<<endl
168 <<i<<
"\t"<<ref[i]-p3d[i]<<endl;
178 for (
int i=0; i<3; i++){
179 if (!
Equal(ref[i]-p3d[i], 0., 1e-13)) {
180 cout <<
"orig: "<<p3d<<
"\nproj: "<<ref<<endl
181 <<i<<
"\t"<<ref[i]-p3d[i]<<endl;
virtual BIAS::Vector3< double > GetC() const
Get projection center.
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.
T * Get(SharedPtr< T > &t)
int XMLRead(const std::string &Filename)
derived classes must implement the function XMLIn which is called by this function XMLRead to read ev...
pointer with reference count and automatic deletion
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.
virtual BIAS::RMatrix GetR() const
Get orientation as rotation matrix R.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
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_...
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
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