My Project
Public Member Functions | List of all members
TrifocalTensor Class Reference

Trifocal tensor works for three images like a fundamental matrix works for two images. More...

#include <TrifocalTensor.h>

Public Member Functions

 TrifocalTensor (const Pose &P1, const Pose &P2)
 Constructs a tensor from identity pose and two other known poses. See computeTensor. More...
 
 TrifocalTensor (const Pose &P0, const Pose &P1, const Pose &P2)
 Constructs a tensor from three known poses. See computeTensor. More...
 
void computeTensor (const Pose &P1, const Pose &P2)
 Initializes the tensor from identity pose and two other known poses. More...
 
void computeTensor (const Pose &P0, const Pose &P1, const Pose &P2)
 Initializes the tensor from three known poses. More...
 
void project (const cv::Point2d &p0, const cv::Point2d &p1, cv::Point2d &p2)
 Computes the projection of a point in the third pose. More...
 
double projectError (const cv::Point2d &p0, const cv::Point2d &p1, const cv::Point2d &p2)
 Computes how much three points differ from the tensor. More...
 

Detailed Description

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.
cv::Point2d proj0, proj1, proj2; // A 3D point projected with poses P0, P1 and P2.
TrifocalTensor T(P1, P2);
cv::Point2d test2;
T.project(proj0, proj1, test2);
assert(proj2.x == test2.x);
assert(proj2.y == test2.y);
assert(proj2.z == test2.z);

Definition at line 71 of file TrifocalTensor.h.

Constructor & Destructor Documentation

◆ TrifocalTensor() [1/2]

TrifocalTensor ( const Pose P1,
const Pose P2 
)

Constructs a tensor from identity pose and two other known poses. See computeTensor.

Parameters
P1The second pose relative to the first pose.
P2The third pose relative to the first pose.

◆ TrifocalTensor() [2/2]

TrifocalTensor ( const Pose P0,
const Pose P1,
const Pose P2 
)

Constructs a tensor from three known poses. See computeTensor.

Parameters
P0The first camera pose.
P1The second pose relative to the first pose.
P2The third pose relative to the first pose.

Member Function Documentation

◆ computeTensor() [1/2]

void computeTensor ( const Pose P0,
const Pose P1,
const Pose P2 
)

Initializes the tensor from three known poses.

Parameters
P0The first camera pose.
P1The second pose relative to the first pose.
P2The third pose relative to the first pose.

◆ computeTensor() [2/2]

void 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.

Parameters
P1The second pose relative to the first pose.
P2The third pose relative to the first pose.

◆ project()

void project ( const cv::Point2d &  p0,
const cv::Point2d &  p1,
cv::Point2d &  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.

Parameters
p02D position in a image projected from the first pose.
p12D position in a image projected from the second pose.
p2Computed 2D position in a image projected form the third pose.

◆ projectError()

double projectError ( const cv::Point2d &  p0,
const cv::Point2d &  p1,
const cv::Point2d &  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.

Parameters
p02D position in a image projected from the first pose.
p12D position in a image projected from the second pose.
p22D position in a image projected form the third pose.
Returns
Squared projection error.

The documentation for this class was generated from the following file: