27 #include "Base/Geometry/KMatrix.hh"
28 #include <MathAlgo/SVD.hh>
29 #include <Base/Math/Vector3.hh>
35 #define F_SVD_THRESH 0.1
59 for (
unsigned int i=0; i<3; i++) {
60 for (
unsigned int j=0; j<3; j++) {
61 if (fabs((*
this)[i][j])>maxentry) maxentry = fabs((*
this)[i][j]);
64 if (maxentry>0.0) (*this) *= 1.0 / maxentry;
73 if ((GetDebugLevel() & D_FMATRIX_GETEPIPOLES)!=0){
75 cerr <<
"F: " << FCopy;
78 for (
int i=0; i<3; i++)
79 S[i][i]=svdF.
GetS()[i];
81 cerr <<
"U:" << svdF.
GetU() <<
"\tS: " << svdF.
GetS() <<
"\tV: "
82 << svdF.
GetVT() <<
"\n U S Vt:"
83 << svdF.
GetU() * S * svdF.
GetVT() <<
"\nF:" << FCopy << endl;
84 cerr <<
"NullspaceDim(): " << svdF.
NullspaceDim() << endl;
111 GetEpipoles(Epipole1, Epipole2);
117 rank3_matrix=skew_matrix*(*this);
141 BIASERR(
"F-Matrix invalid due to wrong nullspace dimension."
142 <<
"dim(N)=" << dimN);
149 const std::vector<BIAS::HomgPoint2D> &p2){
152 int numPoints = std::min(p1.size(), p2.size());
156 for(
int i =0; i < numPoints; i++){
160 res += GetEpipolarError(temp2D_1, temp2D_2);
163 res = res / numPoints;
Vector< double > GetNullvector(const int last_offset=0)
return one of the nullvectors.
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...
bool IsValid()
Returns true if all properties of the F-Matrix are correct, at the moment only rank 2 is checked...
const int NullspaceDim() const
return the dim of the nullspace.
bool GetLeftNullvector(Vector< double > &nv, const int last_offset=0)
Return one of the left nullvectors.
Matrix< T > GetSkewSymmetricMatrix() const
constructs a skew symmetric 3x3 matrix from (*this), which can be used instead of the cross product ...
void DecomposetoSR(BIAS::Matrix3x3< double > &skew_matrix, BIAS::Matrix3x3< double > &rank3_matrix)
Decomposes f matrix to product (skew)(rank3)
double GetResidualError(const std::vector< BIAS::HomgPoint2D > &p1, const std::vector< BIAS::HomgPoint2D > &p2)
returns residual error as in Zisserman p.
const Matrix< double > & GetVT() const
return VT (=transposed(V))
class representing a Fundamental matrix
int GetNullVector(HomgPoint3D &C)
this is another way of getting C, especially interesting for non-metric cameras
const Vector< double > & GetS() const
return S which is a vector of the singular values of A in descending order.
void ComputeFromPMatrices(BIAS::PMatrix &P1, BIAS::PMatrix &P2)
computes an F matrix from two cameras (defined by arbitrary P matrices, not only metric ones) ...
void SetIdentity()
Converts matrix to identity matrix.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
const Matrix< double > & GetU() const
return U U is a m x m orthogonal matrix
FMatrixBase & operator=(const Matrix3x3< FMATRIX_TYPE > &mat)
assignment operators calling corresponding operator from base class "TNT::Matrix" if appropriate ...
int GetEpipoles(HomgPoint2D &Epipole1, HomgPoint2D &Epipole2) const
Computes the epipoles from this F Matrix.
describes a projective 3D -> 2D mapping in homogenous coordinates
FMatrix & operator=(const FMatrix &f)
int GetPseudoInverse(BIAS::Matrix< double > &Pinv)
returns 4x3 pseudo inverse
void SetAsCrossProductMatrix(const Vector3< T > &vec)
Sets matrix from vector as cross product matrix of this vector.
void Set(const HOMGPOINT2D_TYPE &x, const HOMGPOINT2D_TYPE &y)
set elementwise with given 2 euclidean scalar values.
Vector3< T > & Normalize()
normalize this vector to length 1