27 #include <Base/Geometry/Quaternion.hh>
40 if (fabs(normalization)>DBL_EPSILON)
41 Fnorm = (F / normalization );
47 if (fabs(normalization)>DBL_EPSILON)
48 Fnorm = tmp / normalization;
55 tmp[1][1] = tmp[0][0] = 0.5*(S[0]+S[1]);
65 const std::vector<HomgPoint2D> &inlier1,
66 const std::vector<HomgPoint2D> &inlier2)
69 BIASCDOUT(D_EMATRIX_ROT_TRANS,
"EMatrix::GetRotationTranslation()\n");
76 BIASCDOUT(D_EMATRIX_ROT_TRANS,
"epipol = "<<e<<endl);
79 this->GetEpipolesHomogenized(te1, te2);
80 BIASCDOUT(D_EMATRIX_ROT_TRANS,
"epipoles homogenized: te1 = "<<te1
81 <<
"\tte2 = "<<te2<<endl);
84 W[0][1] = -1.0; W[1][0] = 1.0; W[2][2] = 1.0;
86 std::vector<RMatrix> RotCand;
87 BIASCDOUT(D_EMATRIX_ROT_TRANS,
"- Compute rotation candidates : \n");
93 BIASCDOUT(D_EMATRIX_ROT_TRANS,
" R[0] = " << RotCand[0]);
99 BIASCDOUT(D_EMATRIX_ROT_TRANS,
" R[1] = " << RotCand[1]);
103 RotCand[0].GetQuaternion(tmpQ[0]);
104 RotCand[1].GetQuaternion(tmpQ[1]);
105 BIASCDOUT(D_EMATRIX_ROT_TRANS,
" Q[0] = " << tmpQ[0]
106 <<
" (angle = " << tmpQ[0].GetRotationAngle()*180.0/M_PI
107 <<
", axis = " << tmpQ[0].GetRotationAxis() << endl);
108 BIASCDOUT(D_EMATRIX_ROT_TRANS,
" Q[1] = " << tmpQ[1]
109 <<
" (angle = " << tmpQ[1].GetRotationAngle()*180.0/M_PI
110 <<
", axis = " << tmpQ[1].GetRotationAxis() << endl);
115 unsigned int inlier_count, best_inlier_count = 0;
123 for (
unsigned int i = 0; i < RotCand.size(); i++)
125 for (
double base_sign = -1.0; base_sign <= 2.0 ; base_sign += 2.0)
131 RotCand[i].GetQuaternion(Q2);
135 for (
unsigned int n = 0; n < inlier1.size(); n++) {
139 inlier1[n], inlier2[n], eucl3d);
145 if (inlier_count > best_inlier_count){
146 BIASCDOUT(D_EMATRIX_ROT_TRANS,
"- set best inlier count "
147 << inlier_count <<
" for R = " << RotCand[i]
148 <<
"C = " << CCurrent << endl);
149 best_inlier_count = inlier_count;
154 BIASCDOUT(D_EMATRIX_ROT_TRANS,
"- inlier count " << inlier_count
155 <<
" for R = " << RotCand[i] <<
"C = " << CCurrent << endl);
160 if (best_inlier_count == 0) {
161 BIASERR(
"No inlier found during triangulation for essential candidates!");
168 BIASCDOUT(D_EMATRIX_ROT_TRANS,
"-> solution is R = " << R
172 <<
" C = " << C << endl);
181 const vector<HomgPoint2D> &inlier1,
182 const vector<HomgPoint2D> &inlier2)
185 int res = GetRotationTranslation(R, C, inlier1, inlier2);
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
computes and holds the singular value decomposition of a rectangular (not necessarily quadratic) Matr...
void TransposeIP()
tranpose this matrix "in place" example: 0 1 2 –> 0 3 6 3 4 5 –> 1 4 7 6 7 8 –> 2 5 8 ...
Matrix< T > Transpose() const
transpose function, storing data destination matrix
void Set(const HOMGPOINT3D_TYPE &x, const HOMGPOINT3D_TYPE &y, const HOMGPOINT3D_TYPE &z)
set elementwise with given 3 euclidean scalar values.
Vector< T > GetCol(const int &col) const
return a copy of column "col", zero based counting
int Compute(const Matrix< double > &M, double ZeroThreshold=DEFAULT_DOUBLE_ZERO_THRESHOLD)
set a new matrix and compute its decomposition.
void SetZero()
equivalent to matrix call
describes the epipolar relationship between a point and his mapping on a corresponding epipolar line...
int GetQuaternion(Quaternion< ROTATION_MATRIX_TYPE > &quat) const
Calculates quaternion representation for this rotation matrix.
Class for triangulation of 3Dpoints from 2D matches. Covariance matrix (refering to an uncertainty el...
void SetZero()
Sets all values to zero.
double NormFrobenius() const
Vector3< QUAT_TYPE > GetRotationAxis() const
Returns rotation axis.
const Matrix< double > & GetVT() const
return VT (=transposed(V))
class representing a Fundamental matrix
int Triangulate(PMatrix &P1, PMatrix &P2, const HomgPoint2D &p1, const HomgPoint2D &p2, BIAS::Vector3< double > &point3d)
Triangulation for metric PMatrices (using C and Hinf)
QUAT_TYPE GetRotationAngle() const
Returns rotation angle notation in radians.
const Vector< double > & GetS() const
return S which is a vector of the singular values of A in descending order.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
const Matrix< double > & GetU() const
return U U is a m x m orthogonal matrix
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
T GetDeterminant() const
returns the Determinant |A| of this
double NormFrobenius() const
Return Frobenius norm = sqrt(trace(A^t * A)).