43 double data_p12[4][4], data_p13[4][4];
44 CvMat p12 = cvMat( 4, 4, CV_64F, data_p12 );
45 CvMat p13 = cvMat( 4, 4, CV_64F, data_p13 );
49 for (
int i = 0; i < 3; i++)
50 for (
int j = 0; j < 3; j++)
51 for (
int k = 0; k < 3; k++) {
54 (data_p12[j][i] * data_p13[k][3])
56 (data_p12[j][3] * data_p13[k][i]);
64 double det(
double *r0,
double *r1,
double *r2,
double *r3) {
66 memcpy(&m[0], r0, 4*
sizeof(
double));
67 memcpy(&m[4], r1, 4*
sizeof(
double));
68 memcpy(&m[8], r2, 4*
sizeof(
double));
69 memcpy(&m[12], r3, 4*
sizeof(
double));
70 CvMat M = cvMat(4, 4, CV_64F, m);
75 double data_p0[16], data_p1[16], data_p2[16];
76 CvMat P0 = cvMat( 4, 4, CV_64F, data_p0 );
77 CvMat P1 = cvMat( 4, 4, CV_64F, data_p1 );
78 CvMat P2 = cvMat( 4, 4, CV_64F, data_p2 );
83 for (
int i = 0; i < 3; i++)
84 for (
int j = 0; j < 3; j++)
85 for (
int k = 0; k < 3; k++) {
86 double sign = i==1 ? -1 : 1;
87 T[i][j][k] = sign *
det(
getRow(data_p0, (i+1)%3),
96 p1.x * ( p0.x *
T[0][0][l]
100 p1.x * ( p0.x *
T[0][0][l]
104 p1.x * ( p0.x *
T[0][1][l]
108 p1.y * ( p0.x *
T[0][0][l]
112 p1.x * ( p0.x *
T[0][2][l]
115 - ( p0.x *
T[0][0][l]
120 p1.y * ( p0.x *
T[0][0][l]
124 p1.x * ( p0.x *
T[0][1][l]
128 p1.y * ( p0.x *
T[0][1][l]
132 p1.y * ( p0.x *
T[0][1][l]
136 p1.y * ( p0.x *
T[0][2][l]
139 - ( p0.x *
T[0][1][l]
148 p1.x * ( p0.x *
T[0][2][l]
156 p1.y * ( p0.x *
T[0][2][l]
170 if (fabs(v00) > fabs(v)) v = v00;
171 if (fabs(v01) > fabs(v)) v = v01;
172 if (fabs(v02) > fabs(v)) v = v02;
173 if (fabs(v10) > fabs(v)) v = v10;
174 if (fabs(v11) > fabs(v)) v = v11;
175 if (fabs(v12) > fabs(v)) v = v12;
176 if (fabs(v20) > fabs(v)) v = v20;
177 if (fabs(v21) > fabs(v)) v = v21;
178 if (fabs(v22) > fabs(v)) v = v22;
184 const CvPoint2D64f &p1,
192 const CvPoint2D64f &p1,
193 const CvPoint2D64f &p2) {
198 double e0 = v0/v2 - p2.x;
199 double e1 = v1/v2 - p2.y;
double projectAxis(const CvPoint2D64f &p0, const CvPoint2D64f &p1, int l)
void computeTensor(const Pose &P1, const Pose &P2)
Initializes the tensor from identity pose and two other known poses.
double projectError(const CvPoint2D64f &p0, const CvPoint2D64f &p1, const CvPoint2D64f &p2)
Computes how much three points differ from the tensor.
double det(double *r0, double *r1, double *r2, double *r3)
This file implements a trifocal tensor.
Pose representation derived from the Rotation class
double * getRow(double *m, int row)
TFSIMD_FORCE_INLINE const tfScalar & z() const
void project(const CvPoint2D64f &p0, const CvPoint2D64f &p1, CvPoint2D64f &p2)
Computes the projection of a point in the third pose.
void GetMatrix(CvMat *mat) const