34 #include <Base/Common/BIASpragma.hh>
36 #include <Base/Geometry/HomgPoint2D.hh>
37 #include <Geometry/PMatrix.hh>
38 #include <Geometry/RMatrix.hh>
39 #include <Base/Geometry/KMatrix.hh>
40 #include <Base/Math/Random.hh>
41 #include <Utils/ThreeDOut.hh>
43 #include <Geometry/PMatrixLinear.hh>
45 #include <MathAlgo/SVD.hh>
55 unsigned int numPs = 50;
57 vector<PMatrix> P_origs;
58 vector<PMatrix> P_transformed;
69 double phiX, phiY, phiZ;
82 R.
SetXYZ(phiX, phiY, phiZ);
83 for(
int i=0; i < 3; i++){
84 for(
int j=0; j < 3; j++){
94 cout <<
"T " << T << endl;
97 for(
unsigned int i = 0; i < numPs; i++){
104 R.
SetXYZ(phiX, phiY, phiZ);
107 P_origs.push_back(P);
108 P_transformed.push_back(
PMatrix(P*T));
109 R =
RMatrix(P_transformed[i].GetR());
125 for(
int col = 0; col < 4; col++){
126 for(
unsigned int camCount = 0; camCount < numPs; camCount++){
127 for(
int i=0; i < 3; i++){
128 for(
int j = 0; j < 4; j++){
129 A[i+camCount*3][j] = (P_origs[camCount])[i][j];
131 b[i+camCount*3] = (P_transformed[camCount])[i][col];
139 cout << T_col << endl;
140 T_leastSquares[0][col] = T_col[0];
141 T_leastSquares[1][col] = T_col[1];
142 T_leastSquares[2][col] = T_col[2];
143 T_leastSquares[3][col] = T_col[3];
145 cout <<
"Least squares T " << T_leastSquares << endl;
147 SVD svdT(T_leastSquares);
150 vector<PMatrix> P_leastSquares;
152 for(
unsigned int i=0; i < numPs; i++){
153 P_leastSquare =
PMatrix(P_transformed[i] * T_invLS);
155 P_leastSquares.push_back(P_leastSquare);
166 for(
unsigned int i = 0; i < numPs; i++){
167 threeDOut.AddPMatrix(P_origs[i], 400, 400,
RGBAuc(255, 0, 0, 127), 0.1);
170 threeDOut.AddPMatrix(P_leastSquares[i], 400, 400,
RGBAuc(0, 0, 255, 127), 0.1);
176 threeDOut.AddLine(start, end,
RGBAuc(255, 0, 0, 127));
177 end.Set(0.0, 1.0, 0.0);
178 threeDOut.AddLine(start, end,
RGBAuc(0, 255, 0, 127));
179 end.Set(0.0, 0.0, 1.0);
180 threeDOut.AddLine(start, end,
RGBAuc(0, 0, 255, 127));
181 threeDOut.VRMLOut(
"test.wrl");
void SetXYZ(ROTATION_MATRIX_TYPE PhiX, ROTATION_MATRIX_TYPE PhiY, ROTATION_MATRIX_TYPE PhiZ)
Set Euler angles (in rad) in order XYZ.
computes and holds the singular value decomposition of a rectangular (not necessarily quadratic) Matr...
Unified output of 3D entities via OpenGL or VRML.
configuration struct for drawing styles of various 3d objects
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
CameraDrawingStyle CameraStyle
bool DrawUncertaintyEllipsoids
void InvalidateDecomposition()
to re-Decompose_() after filling with data use this.
LineDrawingStyle LineStyle
BIAS::Vector4< unsigned char > RGBAuc
class BIASGeometry_EXPORT PMatrix
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
describes a projective 3D -> 2D mapping in homogenous coordinates
PointDrawingStyle PointStyle
class for producing random numbers from different distributions
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) ...
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...