Visual Servoing Platform
version 3.0.1
|
#include <visp3/vision/vpPose.h>
Public Types | |
enum | vpPoseMethodType { LAGRANGE, DEMENTHON, LOWE, RANSAC, LAGRANGE_LOWE, DEMENTHON_LOWE, VIRTUAL_VS, DEMENTHON_VIRTUAL_VS, LAGRANGE_VIRTUAL_VS } |
enum | FILTERING_RANSAC_FLAGS { PREFILTER_DUPLICATE_POINTS = 0x1, PREFILTER_ALMOST_DUPLICATE_POINTS = 0x2, PREFILTER_DEGENERATE_POINTS = 0x4, CHECK_DEGENERATE_POINTS = 0x8 } |
Static Public Member Functions | |
static void | display (vpImage< unsigned char > &I, vpHomogeneousMatrix &cMo, vpCameraParameters &cam, double size, vpColor col=vpColor::none) |
static void | display (vpImage< vpRGBa > &I, vpHomogeneousMatrix &cMo, vpCameraParameters &cam, double size, vpColor col=vpColor::none) |
static double | poseFromRectangle (vpPoint &p1, vpPoint &p2, vpPoint &p3, vpPoint &p4, double lx, vpCameraParameters &cam, vpHomogeneousMatrix &cMo) |
static int | computeRansacIterations (double probability, double epsilon, const int sampleSize=4, int maxIterations=2000) |
static void | findMatch (std::vector< vpPoint > &p2D, std::vector< vpPoint > &p3D, const unsigned int &numberOfInlierToReachAConsensus, const double &threshold, unsigned int &ninliers, std::vector< vpPoint > &listInliers, vpHomogeneousMatrix &cMo, const int &maxNbTrials=10000) |
Public Attributes | |
unsigned int | npt |
std::list< vpPoint > | listP |
double | residual |
Protected Member Functions | |
double | computeResidualDementhon (const vpHomogeneousMatrix &cMo) |
int | calculArbreDementhon (vpMatrix &b, vpColVector &U, vpHomogeneousMatrix &cMo) |
Protected Attributes | |
double | lambda |
Class used for pose computation from N points (pose from point only). Some of the algorithms implemented in this class are described in [25].
To see how to use this class you can follow the Tutorial: Pose estimation from points.
Methods that could be used to estimate the pose from points.
vpPose::vpPose | ( | ) |
|
virtual |
Destructor that deletes the array of point (freed the memory).
Definition at line 114 of file vpPose.cpp.
References listP.
void vpPose::addPoint | ( | const vpPoint & | newP | ) |
Add a new point in the array of points.
newP | : New point to add in the array of point. |
Definition at line 145 of file vpPose.cpp.
Referenced by vpKeyPoint::computePose(), findMatch(), vpMbTracker::initClick(), vpMbTracker::initFromPoints(), poseFromRectangle(), and poseRansac().
void vpPose::addPoints | ( | const std::vector< vpPoint > & | lP | ) |
Add (append) a list of points in the array of points.
lP | : List of points to add (append). |
Definition at line 161 of file vpPose.cpp.
|
protected |
Definition at line 280 of file vpPoseDementhon.cpp.
References computeResidualDementhon(), vpColVector::dotProd(), npt, vpColVector::sumSquare(), and vpColVector::t().
Referenced by poseDementhonPlan().
void vpPose::clearPoint | ( | ) |
Delete the array of point
Definition at line 130 of file vpPose.cpp.
Referenced by vpMbTracker::initClick().
bool vpPose::computePose | ( | vpPoseMethodType | method, |
vpHomogeneousMatrix & | cMo, | ||
bool(*)(vpHomogeneousMatrix *) | func = NULL |
||
) |
Compute the pose according to the desired method which are:
Definition at line 372 of file vpPose.cpp.
References coplanar(), DEMENTHON, DEMENTHON_LOWE, DEMENTHON_VIRTUAL_VS, LAGRANGE, LAGRANGE_LOWE, LAGRANGE_VIRTUAL_VS, LOWE, vpPoseException::notEnoughPointError, npt, poseDementhonNonPlan(), poseDementhonPlan(), poseLagrangeNonPlan(), poseLagrangePlan(), poseLowe(), poseRansac(), poseVirtualVS(), RANSAC, VIRTUAL_VS, and vpERROR_TRACE.
Referenced by vpKeyPoint::computePose(), findMatch(), vpMbTracker::initClick(), vpMbTracker::initFromPoints(), poseFromRectangle(), and poseRansac().
|
static |
Compute the number of RANSAC iterations to ensure with a probability p that at least one of the random samples of s points is free from outliers.
probability | : Probability that at least one of the random samples is free from outliers (typically p=0.99). |
epsilon | : Probability that a selected point is an outlier (between 0 and 1). |
sampleSize | : Minimum number of points to estimate the model (4 for a pose estimation). |
maxIterations | : Upper bound on the number of iterations or -1 for INT_MAX. |
maxIterations
if it exceeds the desired upper bound or INT_MAX if maxIterations=-1. Definition at line 916 of file vpPoseRansac.cpp.
References vpMath::nul().
double vpPose::computeResidual | ( | const vpHomogeneousMatrix & | cMo | ) | const |
Compute and return the residual expressed in meter for the pose matrix 'cMo'.
cMo | : Input pose. The matrix that defines the pose to be tested. |
Definition at line 337 of file vpPose.cpp.
References vpPoint::get_x(), vpPoint::get_y(), listP, vpMath::sqr(), and vpForwardProjection::track().
Referenced by vpMbTracker::initClick(), vpMbTracker::initFromPoints(), and poseRansac().
|
protected |
Compute and return the residual expressed in meter for the pose matrix 'pose'.
cMo | : the matrix that defines the pose to be tested. |
Definition at line 686 of file vpPoseDementhon.cpp.
References npt, and vpMath::sqr().
Referenced by calculArbreDementhon(), and poseDementhonPlan().
bool vpPose::coplanar | ( | int & | coplanar_plane_type | ) |
Test the coplanarity of the set of points
coplanar_plane_type | 1: if plane x=cst 2: if plane y=cst 3: if plane z=cst 4: if the points are collinear. 0: any other plane |
Definition at line 185 of file vpPose.cpp.
References vpColVector::crossProd(), vpPoint::get_oX(), vpPoint::get_oY(), vpPoint::get_oZ(), listP, vpPoseException::notEnoughPointError, npt, vpMath::sqr(), vpColVector::sumSquare(), vpDEBUG_TRACE, and vpERROR_TRACE.
Referenced by computePose().
|
static |
Display in the image I the pose represented by its homogenous transformation cMo as a 3 axis frame.
I | Image where the pose is displayed in overlay. |
cMo | Considered pose to display. |
cam | Camera parameters associated to image I. |
size | length in meter of the axis that will be displayed |
col | Color used to display the 3 axis. If vpColor::none, red, green and blue will represent x-axiw, y-axis and z-axis respectively. |
Definition at line 574 of file vpPose.cpp.
References vpDisplay::displayFrame().
|
static |
Display in the image I the pose represented by its homogenous transformation cMo as a 3 axis frame.
I | Image where the pose is displayed in overlay. |
cMo | Considered pose to display. |
cam | Camera parameters associated to image I. |
size | length in meter of the axis that will be displayed |
col | Color used to display the 3 axis. If vpColor::none, red, green and blue will represent x-axiw, y-axis and z-axis respectively. |
Definition at line 593 of file vpPose.cpp.
References vpDisplay::displayFrame().
void vpPose::displayModel | ( | vpImage< unsigned char > & | I, |
vpCameraParameters & | cam, | ||
vpColor | col = vpColor::none |
||
) |
Display the coordinates of the points in the image plane that are used to compute the pose in image I.
Definition at line 606 of file vpPose.cpp.
References vpMeterPixelConversion::convertPoint(), vpDisplay::displayCross(), listP, and vpTracker::p.
void vpPose::displayModel | ( | vpImage< vpRGBa > & | I, |
vpCameraParameters & | cam, | ||
vpColor | col = vpColor::none |
||
) |
Display the coordinates of the points in the image plane that are used to compute the pose in image I.
Definition at line 627 of file vpPose.cpp.
References vpMeterPixelConversion::convertPoint(), vpDisplay::displayCross(), listP, and vpTracker::p.
|
static |
Match a vector p2D of 2D point (x,y) and a vector p3D of 3D points (X,Y,Z) using the Ransac algorithm.
At least numberOfInlierToReachAConsensus of true correspondance are required to validate the pose
The inliers are given in a vector of vpPoint listInliers.
The pose is returned in cMo.
p2D | : Vector of 2d points (x and y attributes are used). |
p3D | : Vector of 3d points (oX, oY and oZ attributes are used). |
numberOfInlierToReachAConsensus | : The minimum number of inlier to have to consider a trial as correct. |
threshold | : The maximum error allowed between the 2d points and the reprojection of its associated 3d points by the current pose (in meter). |
ninliers | : Number of inliers found for the best solution. |
listInliers | : Vector of points (2d and 3d) that are inliers for the best solution. |
cMo | : The computed pose (best solution). |
maxNbTrials | : Maximum number of trials before considering a solution fitting the required numberOfInlierToReachAConsensus and threshold cannot be found. |
Definition at line 972 of file vpPoseRansac.cpp.
References addPoint(), computePose(), getRansacInliers(), getRansacNbInliers(), listP, vpPoseException::notEnoughPointError, RANSAC, vpPoint::set_x(), vpPoint::set_y(), setRansacMaxTrials(), setRansacNbInliersToReachConsensus(), setRansacThreshold(), and vpERROR_TRACE.
|
inline |
Get the covariance matrix computed in the Virtual Visual Servoing approach.
Definition at line 254 of file vpPose.h.
References vpTRACE.
Referenced by vpKeyPoint::computePose().
|
inline |
Get the number of threads for the parallel RANSAC implementation.
|
inline |
|
inline |
Definition at line 237 of file vpPose.h.
Referenced by vpKeyPoint::computePose().
|
inline |
Definition at line 238 of file vpPose.h.
Referenced by vpKeyPoint::computePose(), and findMatch().
|
inline |
Definition at line 236 of file vpPose.h.
Referenced by findMatch().
|
inline |
void vpPose::init | ( | void | ) |
void vpPose::poseDementhonNonPlan | ( | vpHomogeneousMatrix & | cMo | ) |
Compute the pose using Dementhon approach for non planar objects this is a direct implementation of the algorithm proposed by Dementhon and Davis in their 1995 paper [12].
Definition at line 62 of file vpPoseDementhon.cpp.
References vpColVector::cross(), vpException::divideByZeroError, vpPoint::get_oX(), vpPoint::get_oY(), vpPoint::get_oZ(), listP, vpColVector::normalize(), npt, vpMatrix::pseudoInverse(), vpColVector::resize(), vpPoint::set_oX(), vpPoint::set_oY(), vpPoint::set_oZ(), vpColVector::sumSquare(), and vpMatrix::t().
Referenced by computePose().
void vpPose::poseDementhonPlan | ( | vpHomogeneousMatrix & | cMo | ) |
Compute the pose using Dementhon approach for planar objects this is a direct implementation of the algorithm proposed by Dementhon in his PhD.
Definition at line 469 of file vpPoseDementhon.cpp.
References calculArbreDementhon(), computeResidualDementhon(), vpColVector::dotProd(), vpPoint::get_oX(), vpPoint::get_oY(), vpPoint::get_oZ(), vpMatrix::getCol(), vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), listP, npt, vpArray2D< Type >::resize(), vpPoint::set_oX(), vpPoint::set_oY(), vpPoint::set_oZ(), vpColVector::sumSquare(), vpMatrix::svd(), vpColVector::t(), vpMatrix::t(), and vpERROR_TRACE.
Referenced by computePose().
|
static |
Carries out the camera pose the image of a rectangle and the intrinsec parameters, the length on x axis is known but the proprtion of the rectangle are unknown.
This method is taken from "Markerless Tracking using Planar Structures in the Scene" by Gilles Simon. The idea is to compute the homography H giving the image point of the rectangle by associating them with the coordinates (0,0)(1,0)(1,1/s)(0,1/s) (the rectangle is on the Z=0 plane). If K is the intrinsec parameters matrix, we have s = ||Kh1||/ ||Kh2||. s gives us the proportion of the rectangle
p1,p2,p3,p4 | the image of the corners of the rectangle (respectively the image of (0,0),(lx,0),(lx,lx/s) and (0,lx/s)) (input) |
cam | the camera used (input) |
lx | the rectangle size on the x axis (input) |
cMo | the camera pose (output) |
Definition at line 665 of file vpPose.cpp.
References addPoint(), computePose(), DEMENTHON_LOWE, vpMatrix::eye(), vpCameraParameters::get_K(), vpPoint::get_x(), vpPoint::get_y(), vpMatrix::getCol(), vpHomography::HLM(), vpMatrix::pseudoInverse(), vpPoint::setWorldCoordinates(), and vpColVector::sumSquare().
void vpPose::poseLagrangeNonPlan | ( | vpHomogeneousMatrix & | cMo | ) |
Definition at line 465 of file vpPoseLagrange.cpp.
References vpException::divideByZeroError, vpPoint::get_oX(), vpPoint::get_oY(), vpPoint::get_oZ(), vpPoint::get_x(), vpPoint::get_y(), listP, npt, and vpColVector::sumSquare().
Referenced by computePose().
void vpPose::poseLagrangePlan | ( | vpHomogeneousMatrix & | cMo, |
const int | coplanar_plane_type = 0 |
||
) |
Compute the pose of a planar object using Lagrange approach.
cMo | : Estimated pose. No initialisation is requested to estimate cMo. |
coplanar_plane_type | : Type of coplanar plane: 1: if plane x=cst 2: if plane y=cst 3: if plane z=cst 0: any other plane |
Definition at line 246 of file vpPoseLagrange.cpp.
References vpException::divideByZeroError, vpPoint::get_oX(), vpPoint::get_oY(), vpPoint::get_oZ(), vpPoint::get_x(), vpPoint::get_y(), listP, npt, and vpColVector::sumSquare().
Referenced by computePose().
void vpPose::poseLowe | ( | vpHomogeneousMatrix & | cMo | ) |
Compute the pose using the Lowe non linear approach it consider the minimization of a residual using the levenberg marquartd approach.
The approach has been proposed by D.G Lowe in 1992 paper [18].
Definition at line 278 of file vpPoseLowe.cpp.
References vpHomogeneousMatrix::extract(), vpPoint::get_oX(), vpPoint::get_oY(), vpPoint::get_oZ(), vpPoint::get_x(), vpPoint::get_y(), vpHomogeneousMatrix::insert(), and listP.
Referenced by computePose().
bool vpPose::poseRansac | ( | vpHomogeneousMatrix & | cMo, |
bool(*)(vpHomogeneousMatrix *) | func = NULL |
||
) |
Compute the pose using the Ransac approach.
cMo | : Computed pose |
func | : Pointer to a function that takes in parameter a vpHomogeneousMatrix and returns true if the pose check is OK or false otherwise |
Definition at line 401 of file vpPoseRansac.cpp.
References addPoint(), CHECK_DEGENERATE_POINTS, computePose(), computeResidual(), DEMENTHON, vpPoint::get_x(), vpPoint::get_y(), vpMath::isNaN(), LAGRANGE, listP, vpPoseException::notInitializedError, npt, PREFILTER_ALMOST_DUPLICATE_POINTS, PREFILTER_DEGENERATE_POINTS, PREFILTER_DUPLICATE_POINTS, setCovarianceComputation(), vpMath::sqr(), vpForwardProjection::track(), and VIRTUAL_VS.
Referenced by computePose().
void vpPose::poseVirtualVS | ( | vpHomogeneousMatrix & | cMo | ) |
Compute the pose using virtual visual servoing approach.
This approach is described in [22].
Definition at line 56 of file vpPoseVirtualVisualServoing.cpp.
References vpMatrix::computeCovarianceMatrixVVS(), vpExponentialMap::direct(), vpPoint::get_x(), vpPoint::get_y(), vpPoint::get_Z(), vpHomogeneousMatrix::inverse(), lambda, listP, vpMatrix::pseudoInverse(), vpColVector::sumSquare(), vpForwardProjection::track(), and vpERROR_TRACE.
Referenced by computePose().
void vpPose::poseVirtualVSrobust | ( | vpHomogeneousMatrix & | cMo | ) |
Compute the pose using virtual visual servoing approach and a robust control law.
This approach is described in [7].
Definition at line 162 of file vpPoseVirtualVisualServoing.cpp.
References vpMatrix::computeCovarianceMatrix(), vpExponentialMap::direct(), vpPoint::get_x(), vpPoint::get_y(), vpPoint::get_Z(), vpArray2D< Type >::getRows(), vpHomogeneousMatrix::inverse(), lambda, listP, vpRobust::MEstimator(), vpArray2D< Type >::resize(), vpColVector::resize(), vpRobust::setIteration(), vpRobust::setThreshold(), vpMath::sqr(), vpColVector::sumSquare(), vpForwardProjection::track(), vpRobust::TUKEY, and vpERROR_TRACE.
void vpPose::printPoint | ( | ) |
Definition at line 551 of file vpPose.cpp.
References vpTracker::cP, listP, vpForwardProjection::oP, vpTracker::p, and vpColVector::t().
|
inline |
Set if the covaraince matrix has to be computed in the Virtual Visual Servoing approach.
flag | : True if the covariance has to be computed, false otherwise. |
Definition at line 245 of file vpPose.h.
Referenced by vpKeyPoint::computePose(), and poseRansac().
void vpPose::setDistanceToPlaneForCoplanarityTest | ( | double | d | ) |
Definition at line 168 of file vpPose.cpp.
|
inline |
Set the number of threads for the parallel RANSAC implementation.
|
inline |
Set RANSAC filtering flags.
flags | : Flags to use, e.g. setRansacFilterFlags(PREFILTER_DUPLICATE_POINTS + CHECK_DEGENERATE_POINTS). |
|
inline |
Definition at line 235 of file vpPose.h.
Referenced by vpKeyPoint::computePose(), and findMatch().
|
inline |
Definition at line 226 of file vpPose.h.
Referenced by vpKeyPoint::computePose(), and findMatch().
|
inline |
Definition at line 227 of file vpPose.h.
References vpException::badValue.
Referenced by vpKeyPoint::computePose(), and findMatch().
|
inline |
Set if parallel RANSAC version should be used or not.
|
protected |
parameters use for the virtual visual servoing approach
Definition at line 106 of file vpPose.h.
Referenced by init(), poseVirtualVS(), and poseVirtualVSrobust().
std::list<vpPoint> vpPose::listP |
Array of point (use here class vpPoint)
Definition at line 101 of file vpPose.h.
Referenced by addPoint(), addPoints(), clearPoint(), computeResidual(), coplanar(), displayModel(), findMatch(), init(), poseDementhonNonPlan(), poseDementhonPlan(), poseLagrangeNonPlan(), poseLagrangePlan(), poseLowe(), poseRansac(), poseVirtualVS(), poseVirtualVSrobust(), printPoint(), and ~vpPose().
unsigned int vpPose::npt |
Number of point used in pose computation.
Definition at line 100 of file vpPose.h.
Referenced by addPoint(), addPoints(), calculArbreDementhon(), clearPoint(), computePose(), computeResidualDementhon(), coplanar(), init(), poseDementhonNonPlan(), poseDementhonPlan(), poseLagrangeNonPlan(), poseLagrangePlan(), and poseRansac().