Trifocal tensor works for three images like a fundamental matrix works for two images. More...
#include <TrifocalTensor.h>
Public Member Functions | |
void | computeTensor (const Pose &P1, const Pose &P2) |
Initializes the tensor from identity pose and two other known poses. | |
void | computeTensor (const Pose &P0, const Pose &P1, const Pose &P2) |
Initializes the tensor from three known poses. | |
void | project (const CvPoint2D64f &p0, const CvPoint2D64f &p1, CvPoint2D64f &p2) |
Computes the projection of a point in the third pose. | |
double | projectError (const CvPoint2D64f &p0, const CvPoint2D64f &p1, const CvPoint2D64f &p2) |
Computes how much three points differ from the tensor. | |
TrifocalTensor () | |
TrifocalTensor (const Pose &P1, const Pose &P2) | |
Constructs a tensor from identity pose and two other known poses. See computeTensor. | |
TrifocalTensor (const Pose &P0, const Pose &P1, const Pose &P2) | |
Constructs a tensor from three known poses. See computeTensor. | |
~TrifocalTensor () | |
Private Member Functions | |
double | projectAxis (const CvPoint2D64f &p0, const CvPoint2D64f &p1, int l) |
Private Attributes | |
double | T [3][3][3] |
Trifocal tensor works for three images like a fundamental matrix works for two images.
Given three camera poses P0, P1, P2 and a 3D point X, we can calculate a trifocal tensor T(P0, P1, P2). The tensor relates projections of X in P0, P1 and P2 in such a way that when any two projections are known the third projection can be calculated.
This implementation of trifocal tensor assumes that the camera poses P0, P1 and P2 are known. When projections of X in P0 and P1 are known the projection in P2 can be computed using the tensor.
The current implementation cannot be used to directly compute the tensor from point correspondencies alone. The implementation can be used for example for optimizing three camera poses when point correspondences are known in the three images by minimizing the trifocal 'projection error' computed by projectError -method.
Pose P1, P2; // P0 is identity pose. CvPoint2D64f proj0, proj1, proj2; // A 3D point projected with poses P0, P1 and P2. TrifocalTensor T(P1, P2); CvPoint2D64f test2; T.project(proj0, proj1, test2); assert(proj2.x == test2.x); assert(proj2.y == test2.y); assert(proj2.z == test2.z);
Definition at line 70 of file TrifocalTensor.h.
Definition at line 28 of file TrifocalTensor.cpp.
alvar::TrifocalTensor::TrifocalTensor | ( | const Pose & | P1, |
const Pose & | P2 | ||
) |
Constructs a tensor from identity pose and two other known poses. See computeTensor.
P1 | The second pose relative to the first pose. |
P2 | The third pose relative to the first pose. |
Definition at line 31 of file TrifocalTensor.cpp.
alvar::TrifocalTensor::TrifocalTensor | ( | const Pose & | P0, |
const Pose & | P1, | ||
const Pose & | P2 | ||
) |
Constructs a tensor from three known poses. See computeTensor.
P0 | The first camera pose. |
P1 | The second pose relative to the first pose. |
P2 | The third pose relative to the first pose. |
Definition at line 35 of file TrifocalTensor.cpp.
Definition at line 39 of file TrifocalTensor.cpp.
void alvar::TrifocalTensor::computeTensor | ( | const Pose & | P1, |
const Pose & | P2 | ||
) |
Initializes the tensor from identity pose and two other known poses.
The first pose is identity and the two other poses are relative translations/rotation between the first and the second pose and between the first and the third pose.
P1 | The second pose relative to the first pose. |
P2 | The third pose relative to the first pose. |
Definition at line 42 of file TrifocalTensor.cpp.
void alvar::TrifocalTensor::computeTensor | ( | const Pose & | P0, |
const Pose & | P1, | ||
const Pose & | P2 | ||
) |
Initializes the tensor from three known poses.
P0 | The first camera pose. |
P1 | The second pose relative to the first pose. |
P2 | The third pose relative to the first pose. |
Definition at line 74 of file TrifocalTensor.cpp.
void alvar::TrifocalTensor::project | ( | const CvPoint2D64f & | p0, |
const CvPoint2D64f & | p1, | ||
CvPoint2D64f & | p2 | ||
) |
Computes the projection of a point in the third pose.
When we have three images, each a projection of a scene from the three different camera poses (identity and the two poses that were used to initialize the tensor) and a 2D point correspondence between the first and the second images, a position in the third image is computed.
p0 | 2D position in a image projected from the first pose. |
p1 | 2D position in a image projected from the second pose. |
p2 | Computed 2D position in a image projected form the third pose. |
Definition at line 183 of file TrifocalTensor.cpp.
double alvar::TrifocalTensor::projectAxis | ( | const CvPoint2D64f & | p0, |
const CvPoint2D64f & | p1, | ||
int | l | ||
) | [private] |
Definition at line 94 of file TrifocalTensor.cpp.
double alvar::TrifocalTensor::projectError | ( | const CvPoint2D64f & | p0, |
const CvPoint2D64f & | p1, | ||
const CvPoint2D64f & | p2 | ||
) |
Computes how much three points differ from the tensor.
When we have three images, each a projection of a scene from the three different camera poses (identity and the two poses that were used to initialize the tensor) and a 2D point correspondence between the first the second and the third images, we compute how well the three projections match with the trifocal tensor.
When the third point lies exactly where the tensor projects the first two points, the returned error is zero.
p0 | 2D position in a image projected from the first pose. |
p1 | 2D position in a image projected from the second pose. |
p2 | 2D position in a image projected form the third pose. |
Definition at line 191 of file TrifocalTensor.cpp.
double alvar::TrifocalTensor::T[3][3][3] [private] |
Definition at line 72 of file TrifocalTensor.h.