33 #include "Geometry/CamPoseCalib.hh"
34 #include "Base/Math/Random.hh"
41 double boxSize=10, boxDepth=1, boxDistance=30;
42 double sigmaNoise=0.5, outlier=5;
45 int main(
int,
char **)
49 std::vector<Vector3<double> > mps;
51 for (
int i=0;i<nrPoints;i++) {
55 boxDistance+boxDepth/2.0);
63 double fx=912/2.0,fy=912/2.0,cx=383/2.0,cy=287/2.0;
64 cx=343/2.0,cy=247/2.0;
75 D_BIAS_CAMPOSE_ESTIMATE_ITER);
82 "---- estimating external parameters --------"<<endl;
87 K[0][0]= fx; K[0][2]= cx;
88 K[1][0]= 0; K[1][1]= fy; K[1][2]= cy;
98 K[0][0]= fx ; K[0][2]= cx;
99 K[1][1]= fy; K[1][2]= cy;
100 R.
SetXYZ(0, -45.0/180.0*M_PI, 0/180.0*M_PI);
108 std::vector<Vector2<double> > tps;
111 for (
unsigned int i=0;i<mps.size();i++) {
117 if (sigmaNoise>1E-15)
118 for (
unsigned int i=0;i<tps.size();i++) {
124 if (percentOutlier>0.000001)
125 for (
unsigned int i=0;i<tps.size()/(percentOutlier*100);) {
127 if (fabs(offset)>(3*sigmaNoise)) {
132 if (fabs(offset)>(3*sigmaNoise)) {
148 for (
unsigned int i=0;i<mps.size();i++) {
149 estimator.
AddCorr(mps[i],tps[i]);
158 cout<<
"estimated R:"<<resR<<endl;
162 cout<<
"Rotation axis:"<<axis<<
" angle:"<<angle/M_PI*180.0<<endl;
165 estimator.
GetP(Pest);
168 cout<<
"avg error:"<<estimator.
GetAvgError()<<endl<<
169 " y5:"<<tps[4]<<
" estimatedP*mp5:"<<yEst<<endl;
170 cout<<
"Real K:"<<K<<endl
171 <<
"Estimated K:"<<Pest.
GetK()<<endl;
174 cout<<
"CoVariance of Estimation:"<<coVar<<endl;
179 "---- Reestimating with principal point and Huber weighting function ----"
188 cout<<
"estimated R:"<<resR<<endl;
190 cout<<
"Rotation axis:"<<axis<<
" angle:"<<angle/M_PI*180.0<<endl;
192 estimator.
GetP(Pest);
194 cout<<
"avg error:"<<estimator.
GetAvgError()<<endl<<
195 " y5:"<<tps[4]<<
" estimatedP*mp5:"<<yEst<<endl;
196 cout<<
"Real K:"<<K<<endl
197 <<
"Estimated K:"<<Pest.
GetK()<<endl;
199 cout<<
"CoVariance of Estimation:"<<coVar<<endl;
void Set(const T *pv)
copy the array of vectorsize beginning at *T to this->data_
void SetXYZ(ROTATION_MATRIX_TYPE PhiX, ROTATION_MATRIX_TYPE PhiY, ROTATION_MATRIX_TYPE PhiZ)
Set Euler angles (in rad) in order XYZ.
int GetCoVarMatrix(BIAS::Matrix< double > &coVar)
returns the covariance of the last estimate, which is (H=Hessian): H^{-1} * eps^T*eps * 1/(2n-p) The ...
BIAS::Vector3< double > GetTranslation() const
this returns the translation from the initial camera center to the new camera center ...
this classs allows estimation of the internal (except skew) and external camera parameters by an iter...
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
double GetAvgError()
returns the avg error of the estimation, which is the average difference of the projected points to t...
int GetDebugLevel() const
void GetP(BIAS::PMatrix &P)
returns the estimated new projection matrix
void SetEstimatePrincipal(bool yes)
wether to estimate the principal point also, default is NO
int SetInitialCamera(const BIAS::KMatrix &K)
activates an automatic initial guess for the projection matrix, according to Christian Perwass' habil...
void SetDebugLevel(const long int lv)
BIAS::RMatrix GetRotation() const
this return the relative rotation from the initial camera orientation to the new estimated camera rot...
void SetWeighting(double k, int func=1)
optional: do robust estimation, if the error is larger than k, an outlier is assumed ...
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
int GetRotationAxisAngle(Vector3< ROTATION_MATRIX_TYPE > &axis, ROTATION_MATRIX_TYPE &angle) const
Calculates angle and rotation axis representation for this rotation matrix.
double GetNormalDistributed(const double mean, const double sigma)
on succesive calls return normal distributed random variable with mean and standard deviation sigma ...
describes a projective 3D -> 2D mapping in homogenous coordinates
int AddCorr(const BIAS::Vector3< double > &x, const BIAS::Vector2< double > &y)
add a corresponding point pair
class for producing random numbers from different distributions
class BIASGeometryBase_EXPORT HomgPoint2D
void Compose(const Matrix3x3< double > &K, const Matrix3x3< double > &R, const Vector3< double > &C)
composes this from K, R and C using P = [ K R' | -K R' C ] with R' = transpose(R) ...
class BIASGeometryBase_EXPORT HomgPoint3D
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...
int Estimate(unsigned int iterations=20)
Does the calculation with a certain number of iterations.
int GetK(KMatrix &K)
calibration matrix