C# Class Accord.Math.Geometry.CoplanarPosit

3D pose estimation algorithm (coplanar case).

The class implements an algorithm for 3D object's pose estimation from it's 2D coordinates obtained by perspective projection, when the object is described coplanar points. The idea of the implemented math and algorithm is described in "Iterative Pose Estimation using Coplanar Feature Points" paper written by Oberkampf, Daniel DeMenthon and Larry Davis (the implementation of the algorithm is very close translation of the pseudo code given by the paper, so should be easy to follow).

At this point the implementation works only with models described by 4 points, which is the minimum number of points enough for 3D pose estimation.

The 4 model's point are supposed to be coplanar, i.e. supposed to reside all within same planer. See Posit for none coplanar case.

Read 3D Pose Estimation article for additional information and samples.

Sample usage:

// points of real object - model Vector3[] copositObject = new Vector3[4] { new Vector3( -56.5f, 0, 56.5f ), new Vector3( 56.5f, 0, 56.5f ), new Vector3( 56.5f, 0, -56.5f ), new Vector3( -56.5f, 0, -56.5f ), }; // focal length of camera used to capture the object float focalLength = 640; // depends on your camera or projection system // initialize CoPOSIT object CoplanarPosit coposit = new CoplanarPosit( copositObject, focalLength ); // 2D points of te object - projection Accord.Point[] projectedPoints = new Accord.Point[4] { new Accord.Point( -77, 48 ), new Accord.Point( 44, 66 ), new Accord.Point( 75, -36 ), new Accord.Point( -61, -58 ), }; // estimate pose Matrix3x3 rotationMatrix; Vector3 translationVector; coposit.EstimatePose( projectedPoints, out rotationMatrix, out translationVector );
Show file Open project: accord-net/framework Class Usage Examples

Public Methods

Method Description
CoplanarPosit ( Vector3 model, float focalLength ) : System

Initializes a new instance of the Posit class.

EstimatePose ( Point points, AForge.Math.Matrix3x3 &rotation, Vector3 &translation ) : void

Estimate pose of a model from it's projected 2D coordinates.

Because of the Coplanar POSIT algorithm's nature, it provides two pose estimations, which are valid from the algorithm's math point of view. For each pose an error is calculated, which specifies how good estimation fits to the specified real 2D coordinated. The method provides the best estimation through its output parameters rotation and translation. This may be enough for many of the pose estimation application. For those, who require checking the alternate pose estimation, it can be obtained using AlternateEstimatedRotation and AlternateEstimatedTranslation properties. The calculated error is provided for both estimations through BestEstimationError and AlternateEstimationError properties.

Private Methods

Method Description
GetError ( Point imagePoints, AForge.Math.Matrix3x3 rotation, Vector3 translation ) : float
Iterate ( Point points, AForge.Math.Matrix3x3 &rotation, Vector3 &translation ) : float
POS ( Point imagePoints, Vector3 eps, AForge.Math.Matrix3x3 &rotation1, AForge.Math.Matrix3x3 &rotation2, Vector3 &translation1, Vector3 &translation2 ) : void

Method Details

CoplanarPosit() public method

Initializes a new instance of the Posit class.
The model must have 4 points.
public CoplanarPosit ( Vector3 model, float focalLength ) : System
model Vector3 Array of vectors containing coordinates of four real model's point.
focalLength float Effective focal length of the camera used to capture the model.
return System

EstimatePose() public method

Estimate pose of a model from it's projected 2D coordinates.

Because of the Coplanar POSIT algorithm's nature, it provides two pose estimations, which are valid from the algorithm's math point of view. For each pose an error is calculated, which specifies how good estimation fits to the specified real 2D coordinated. The method provides the best estimation through its output parameters rotation and translation. This may be enough for many of the pose estimation application. For those, who require checking the alternate pose estimation, it can be obtained using AlternateEstimatedRotation and AlternateEstimatedTranslation properties. The calculated error is provided for both estimations through BestEstimationError and AlternateEstimationError properties.

4 points must be be given for pose estimation.
public EstimatePose ( Point points, AForge.Math.Matrix3x3 &rotation, Vector3 &translation ) : void
points Point 4 2D points of the model's projection.
rotation AForge.Math.Matrix3x3 Gets best estimation of object's rotation.
translation Vector3 Gets best estimation of object's translation.
return void