Visual Servoing Platform  version 3.6.1 under development (2024-04-25)
vpMbtDistanceKltPoints Class Reference

#include <visp3/mbt/vpMbtDistanceKltPoints.h>

Public Member Functions

 vpMbtDistanceKltPoints ()
 
virtual ~vpMbtDistanceKltPoints ()
 
unsigned int computeNbDetectedCurrent (const vpKltOpencv &_tracker, const vpImage< bool > *mask=nullptr)
 
void computeHomography (const vpHomogeneousMatrix &_cTc0, vpHomography &cHc0)
 
void computeInteractionMatrixAndResidu (vpColVector &_R, vpMatrix &_J)
 
void display (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
 
void display (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
 
void displayPrimitive (const vpImage< unsigned char > &_I)
 
void displayPrimitive (const vpImage< vpRGBa > &_I)
 
std::vector< std::vector< double > > getFeaturesForDisplay ()
 
std::vector< std::vector< double > > getModelForDisplay (const vpCameraParameters &cam, bool displayFullModel=false)
 
vpCameraParametersgetCameraParameters ()
 
vpColVector getCurrentNormal () const
 
std::map< int, vpImagePoint > & getCurrentPoints ()
 
std::map< int, int > & getCurrentPointsInd ()
 
unsigned int getInitialNumberPoint () const
 
unsigned int getCurrentNumberPoints () const
 
bool hasEnoughPoints () const
 
void init (const vpKltOpencv &_tracker, const vpImage< bool > *mask=nullptr)
 
bool isTracked () const
 
void removeOutliers (const vpColVector &weight, const double &threshold_outlier)
 
virtual void setCameraParameters (const vpCameraParameters &_cam)
 
void setTracked (const bool &track)
 
void updateMask (cv::Mat &mask, unsigned char _nb=255, unsigned int _shiftBorder=0)
 

Public Attributes

vpMbtPolygonpolygon
 
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
 
bool useScanLine
 

Detailed Description

Implementation of a polygon of the model containing points of interest. It is used by the model-based tracker KLT, and hybrid.

Warning
This class is only available if OpenCV is installed, and used.

Definition at line 63 of file vpMbtDistanceKltPoints.h.

Constructor & Destructor Documentation

◆ vpMbtDistanceKltPoints()

vpMbtDistanceKltPoints::vpMbtDistanceKltPoints ( )

Basic constructor.

Definition at line 54 of file vpMbtDistanceKltPoints.cpp.

◆ ~vpMbtDistanceKltPoints()

vpMbtDistanceKltPoints::~vpMbtDistanceKltPoints ( )
virtual

Basic destructor.

Definition at line 65 of file vpMbtDistanceKltPoints.cpp.

Member Function Documentation

◆ computeHomography()

void vpMbtDistanceKltPoints::computeHomography ( const vpHomogeneousMatrix _cTc0,
vpHomography _cHc0 
)

Compute the homography using a displacement matrix.

the homography is given by:

$ {}^cH_{c_0} = {}^cR_{c_0} + \frac{{}^cT_{c_0} . {}^tN}{d_0} $

Several internal variables are computed (dt, cRc0_0n).

Parameters
_cTc0: The displacement matrix of the camera between the initial position of the camera and the current camera position
_cHc0: The homography of the plane.

Definition at line 280 of file vpMbtDistanceKltPoints.cpp.

References vpHomography::convert(), and vpHomogeneousMatrix::extract().

Referenced by vpMbEdgeKltTracker::computeVVS(), and vpMbKltTracker::computeVVSInteractionMatrixAndResidu().

◆ computeInteractionMatrixAndResidu()

void vpMbtDistanceKltPoints::computeInteractionMatrixAndResidu ( vpColVector _R,
vpMatrix _J 
)

Compute the interaction matrix and the residu vector for the face. The method assumes that these two objects are properly sized in order to be able to improve the speed with the use of SubCoVector and subMatrix.

Warning
The function preCompute must be called before the this method.
Parameters
_R: the residu vector
_J: the interaction matrix

Definition at line 191 of file vpMbtDistanceKltPoints.cpp.

References vpPixelMeterConversion::convertPoint().

Referenced by vpMbEdgeKltTracker::computeVVS(), and vpMbKltTracker::computeVVSInteractionMatrixAndResidu().

◆ computeNbDetectedCurrent()

unsigned int vpMbtDistanceKltPoints::computeNbDetectedCurrent ( const vpKltOpencv _tracker,
const vpImage< bool > *  mask = nullptr 
)

compute the number of point in this instanciation of the tracker that corresponds to the points of the face

Parameters
_tracker: the KLT tracker
Returns
the number of points that are tracked in this face and in this instanciation of the tracker
Parameters
maskMask image or nullptr if not wanted. Mask values that are set to true are considered in the tracking. To disable a pixel, set false.

Definition at line 150 of file vpMbtDistanceKltPoints.cpp.

References vpKltOpencv::getFeature(), vpKltOpencv::getNbFeatures(), and vpMeTracker::inRoiMask().

Referenced by vpMbKltTracker::preTracking().

◆ display() [1/2]

void vpMbtDistanceKltPoints::display ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
const vpColor col,
unsigned int  thickness = 1,
bool  displayFullModel = false 
)

Definition at line 552 of file vpMbtDistanceKltPoints.cpp.

References vpDisplay::displayLine(), and getModelForDisplay().

◆ display() [2/2]

void vpMbtDistanceKltPoints::display ( const vpImage< vpRGBa > &  I,
const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
const vpColor col,
unsigned int  thickness = 1,
bool  displayFullModel = false 
)

Definition at line 566 of file vpMbtDistanceKltPoints.cpp.

References vpDisplay::displayLine(), and getModelForDisplay().

◆ displayPrimitive() [1/2]

void vpMbtDistanceKltPoints::displayPrimitive ( const vpImage< unsigned char > &  _I)

Display the primitives tracked for the face.

Parameters
_I: The image where to display.

Definition at line 509 of file vpMbtDistanceKltPoints.cpp.

References vpDisplay::displayCross(), vpDisplay::displayText(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpColor::red, vpMath::round(), vpImagePoint::set_i(), and vpImagePoint::set_j().

◆ displayPrimitive() [2/2]

void vpMbtDistanceKltPoints::displayPrimitive ( const vpImage< vpRGBa > &  _I)

Display the primitives tracked for the face.

Parameters
_I: The image where to display.

Definition at line 533 of file vpMbtDistanceKltPoints.cpp.

References vpDisplay::displayCross(), vpDisplay::displayText(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpColor::red, vpMath::round(), vpImagePoint::set_i(), and vpImagePoint::set_j().

◆ getCameraParameters()

vpCameraParameters& vpMbtDistanceKltPoints::getCameraParameters ( )
inline

Get the camera parameters of the face.

Returns
cam : the camera parameters of the face.

Definition at line 157 of file vpMbtDistanceKltPoints.h.

◆ getCurrentNormal()

vpColVector vpMbtDistanceKltPoints::getCurrentNormal ( ) const
inline

Definition at line 159 of file vpMbtDistanceKltPoints.h.

◆ getCurrentNumberPoints()

unsigned int vpMbtDistanceKltPoints::getCurrentNumberPoints ( ) const
inline

Get the number of points detected in the last image.

Warning
To have the real number of points, the function computeNbDetectedCurrent() must be called first.
Returns
the number of points detected in the current image.
See also
getInitialNumberPoint()

Definition at line 184 of file vpMbtDistanceKltPoints.h.

Referenced by vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVSInteractionMatrixAndResidu(), vpMbKltTracker::postTracking(), vpMbKltTracker::preTracking(), and vpMbKltTracker::testTracking().

◆ getCurrentPoints()

std::map<int, vpImagePoint>& vpMbtDistanceKltPoints::getCurrentPoints ( )
inline

Definition at line 161 of file vpMbtDistanceKltPoints.h.

Referenced by vpMbKltTracker::setPose().

◆ getCurrentPointsInd()

std::map<int, int>& vpMbtDistanceKltPoints::getCurrentPointsInd ( )
inline

Definition at line 163 of file vpMbtDistanceKltPoints.h.

Referenced by vpMbKltTracker::setPose().

◆ getFeaturesForDisplay()

std::vector< std::vector< double > > vpMbtDistanceKltPoints::getFeaturesForDisplay ( )

Return a list of features parameters for display.

  • Parameters are: <feature id (here 1 for KLT)>, <pt.i()>, <pt.j()>, <klt_id.i()>, <klt_id.j()>, <klt_id.id>

Definition at line 585 of file vpMbtDistanceKltPoints.cpp.

References vpImagePoint::get_i(), vpImagePoint::get_j(), vpMath::round(), vpImagePoint::set_i(), and vpImagePoint::set_j().

Referenced by vpMbKltTracker::getFeaturesForDisplayKlt().

◆ getInitialNumberPoint()

unsigned int vpMbtDistanceKltPoints::getInitialNumberPoint ( ) const
inline

Get the number of point that was belonging to the face at the initialisation

Returns
the number of initial point.
See also
getCurrentNumberPoints()

Definition at line 173 of file vpMbtDistanceKltPoints.h.

Referenced by vpMbKltTracker::postTracking().

◆ getModelForDisplay()

std::vector< std::vector< double > > vpMbtDistanceKltPoints::getModelForDisplay ( const vpCameraParameters camera,
bool  displayFullModel = false 
)

Return a list of line parameters to display the primitive at a given pose and camera parameters. Parameters are: <primitive id (here 0 for line)>, <pt_start.i()>, <pt_start.j()> <pt_end.i()>, <pt_end.j()>

Parameters
camera: The camera parameters.
displayFullModel: If true, the line is displayed even if it is not

Definition at line 615 of file vpMbtDistanceKltPoints.cpp.

References vpMbHiddenFaces< PolygonType >::computeScanLineQuery(), vpMeterPixelConversion::convertPoint(), vpPolygon3D::DOWN_CLIPPING, vpPolygon3D::FAR_CLIPPING, vpImagePoint::get_i(), vpImagePoint::get_j(), vpPolygon3D::getPolygonClipped(), hiddenface, vpMbtPolygon::isVisible(), vpPolygon3D::LEFT_CLIPPING, vpPolygon3D::NEAR_CLIPPING, polygon, vpPolygon3D::RIGHT_CLIPPING, vpPolygon3D::UP_CLIPPING, and useScanLine.

Referenced by display(), and vpMbKltTracker::getModelForDisplay().

◆ hasEnoughPoints()

◆ init()

void vpMbtDistanceKltPoints::init ( const vpKltOpencv _tracker,
const vpImage< bool > *  mask = nullptr 
)

Initialise the face to track. All the points in the map, representing all the map detected in the image, are parsed in order to extract the id of the points that are indeed in the face.

Parameters
_tracker: ViSP OpenCV KLT Tracker.
maskMask image or nullptr if not wanted. Mask values that are set to true are considered in the tracking. To disable a pixel, set false.

Definition at line 76 of file vpMbtDistanceKltPoints.cpp.

References vpPlane::getD(), vpKltOpencv::getFeature(), vpMbtPolygon::getIndex(), vpMbHiddenFaces< PolygonType >::getMbScanLineRenderer(), vpKltOpencv::getNbFeatures(), vpPlane::getNormal(), vpPolygon3D::getPoint(), vpPolygon3D::getRoiClipped(), hiddenface, vpMeTracker::inRoiMask(), vpPolygon::isInside(), vpColVector::normalize(), polygon, and useScanLine.

Referenced by vpMbKltTracker::reinit(), and vpMbKltTracker::setPose().

◆ isTracked()

bool vpMbtDistanceKltPoints::isTracked ( ) const
inline

◆ removeOutliers()

void vpMbtDistanceKltPoints::removeOutliers ( const vpColVector _w,
const double &  threshold_outlier 
)

This method removes the outliers. A point is considered as outlier when its associated weight is below a given threshold (threshold_outlier).

Parameters
_w: Vector containing the weight of all the tracked points.
threshold_outlier: Threshold to specify wether or not a point has to be deleted.

Definition at line 470 of file vpMbtDistanceKltPoints.cpp.

Referenced by vpMbKltTracker::postTracking().

◆ setCameraParameters()

virtual void vpMbtDistanceKltPoints::setCameraParameters ( const vpCameraParameters _cam)
inlinevirtual

Set the camera parameters

Parameters
_cam: the new camera parameters

Definition at line 204 of file vpMbtDistanceKltPoints.h.

Referenced by vpMbKltTracker::initFaceFromCorners(), vpMbKltTracker::initFaceFromLines(), and vpMbKltTracker::setCameraParameters().

◆ setTracked()

void vpMbtDistanceKltPoints::setTracked ( const bool &  track)
inline

Set if the klt points have to considered during tracking phase.

Parameters
track: True if they have to be tracked, False otherwise.

Definition at line 211 of file vpMbtDistanceKltPoints.h.

Referenced by vpMbKltTracker::setUseKltTracking().

◆ updateMask()

void vpMbtDistanceKltPoints::updateMask ( cv::Mat &  mask,
unsigned char  nb = 255,
unsigned int  shiftBorder = 0 
)

Modification of all the pixels that are in the roi to the value of _nb ( default is 255).

Parameters
mask: the mask to update (0, not in the object, _nb otherwise).
nb: Optional value to set to the pixels included in the face.
shiftBorder: Optional shift for the border in pixel (sort of built-in erosion) to avoid to consider pixels near the limits of the face.

Definition at line 351 of file vpMbtDistanceKltPoints.cpp.

References vpPolygon::buildFrom(), vpPolygon::getArea(), vpPolygon3D::getMinMaxRoi(), vpPolygon3D::getRoiClipped(), vpPolygon::isInside(), polygon, and vpImagePoint::set_ij().

Referenced by vpMbKltTracker::reinit().

Member Data Documentation

◆ hiddenface

vpMbHiddenFaces<vpMbtPolygon>* vpMbtDistanceKltPoints::hiddenface

Pointer to the list of faces.

Definition at line 104 of file vpMbtDistanceKltPoints.h.

Referenced by getModelForDisplay(), init(), vpMbKltTracker::initFaceFromCorners(), and vpMbKltTracker::initFaceFromLines().

◆ polygon

◆ useScanLine

bool vpMbtDistanceKltPoints::useScanLine