Visual Servoing Platform  version 3.6.1 under development (2024-11-21)
vpMbtFaceDepthNormal Class Reference

#include <visp3/mbt/vpMbtFaceDepthNormal.h>

Public Types

enum  vpFaceCentroidType { GEOMETRIC_CENTROID , MEAN_CENTROID }
 
enum  vpFeatureEstimationType { ROBUST_FEATURE_ESTIMATION = 0 , ROBUST_SVD_PLANE_ESTIMATION = 1 , PCL_PLANE_ESTIMATION = 2 }
 

Public Member Functions

 vpMbtFaceDepthNormal ()
 
virtual ~vpMbtFaceDepthNormal ()
 
void addLine (vpPoint &p1, vpPoint &p2, vpMbHiddenFaces< vpMbtPolygon > *const faces, vpUniRand &rand_gen, int polygon=-1, std::string name="")
 
bool computeDesiredFeatures (const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height, const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &point_cloud, vpColVector &desired_features, unsigned int stepX, unsigned int stepY, const vpImage< bool > *mask=nullptr)
 
bool computeDesiredFeatures (const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height, const std::vector< vpColVector > &point_cloud, vpColVector &desired_features, unsigned int stepX, unsigned int stepY, const vpImage< bool > *mask=nullptr)
 
bool computeDesiredFeatures (const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height, const vpMatrix &point_cloud, vpColVector &desired_features, unsigned int stepX, unsigned int stepY, const vpImage< bool > *mask=nullptr)
 
void computeInteractionMatrix (const vpHomogeneousMatrix &cMo, vpMatrix &L, vpColVector &features)
 
void computeVisibility ()
 
void computeVisibilityDisplay ()
 
bool planeIsInvalid (const vpHomogeneousMatrix &cMo, double maxAngle)
 
void computeNormalVisibility (double nx, double ny, double nz, const vpColVector &centroid_point, vpColVector &face_normal)
 
void computeNormalVisibility (float nx, float ny, float nz, const pcl::PointXYZ &centroid_point, pcl::PointXYZ &face_normal)
 
void computeNormalVisibility (double nx, double ny, double nz, const vpHomogeneousMatrix &cMo, const vpCameraParameters &camera, vpColVector &correct_normal, vpPoint &centroid)
 
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 displayFeature (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double scale=0.05, unsigned int thickness=1)
 
void displayFeature (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double scale=0.05, unsigned int thickness=1)
 
std::vector< std::vector< double > > getFeaturesForDisplay (const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double scale=0.05)
 
std::vector< std::vector< double > > getModelForDisplay (unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)
 
bool isTracked () const
 
bool isVisible () const
 
void setCameraParameters (const vpCameraParameters &camera)
 
void setFaceCentroidMethod (const vpFaceCentroidType &method)
 
void setFeatureEstimationMethod (const vpFeatureEstimationType &method)
 
void setPclPlaneEstimationMethod (int method)
 
void setPclPlaneEstimationRansacMaxIter (int maxIter)
 
void setPclPlaneEstimationRansacThreshold (double threshold)
 
void setScanLineVisibilityTest (bool v)
 
void setTracked (bool tracked)
 

Public Attributes

vpCameraParameters m_cam
 
unsigned int m_clippingFlag
 
double m_distFarClip
 
double m_distNearClip
 
vpMbHiddenFaces< vpMbtPolygon > * m_hiddenFace
 
vpPlane m_planeObject
 
vpMbtPolygonm_polygon
 
bool m_useScanLine
 

Protected Member Functions

bool computeDesiredFeaturesPCL (const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &point_cloud_face, vpColVector &desired_features, vpColVector &desired_normal, vpColVector &centroid_point)
 
void computeDesiredFeaturesRobustFeatures (const std::vector< double > &point_cloud_face_custom, const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &desired_features, vpColVector &desired_normal, vpColVector &centroid_point)
 
void computeDesiredFeaturesSVD (const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &desired_features, vpColVector &desired_normal, vpColVector &centroid_point)
 
void computeDesiredNormalAndCentroid (const vpHomogeneousMatrix &cMo, const vpColVector &desired_normal, const vpColVector &centroid_point)
 
bool computePolygonCentroid (const std::vector< vpPoint > &points, vpPoint &centroid)
 
void computeROI (const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height, std::vector< vpImagePoint > &roiPts)
 
void estimateFeatures (const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &x_estimated, std::vector< double > &weights)
 
void estimatePlaneEquationSVD (const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &plane_equation_estimated, vpColVector &centroid)
 
bool samePoint (const vpPoint &P1, const vpPoint &P2) const
 

Protected Attributes

bool m_faceActivated
 
vpFaceCentroidType m_faceCentroidMethod
 
vpPoint m_faceDesiredCentroid
 
vpPoint m_faceDesiredNormal
 
vpFeatureEstimationType m_featureEstimationMethod
 
bool m_isTrackedDepthNormalFace
 
bool m_isVisible
 
std::vector< vpMbtDistanceLine * > m_listOfFaceLines
 
vpPlane m_planeCamera
 
int m_pclPlaneEstimationMethod
 
int m_pclPlaneEstimationRansacMaxIter
 
double m_pclPlaneEstimationRansacThreshold
 
std::vector< PolygonLine > m_polygonLines
 

Detailed Description

Definition at line 54 of file vpMbtFaceDepthNormal.h.

Member Enumeration Documentation

◆ vpFaceCentroidType

How to compute the centroid of a face using depth feature.

Enumerator
GEOMETRIC_CENTROID 

Compute the geometric centroid.

MEAN_CENTROID 

Compute the mean centroid.

Definition at line 60 of file vpMbtFaceDepthNormal.h.

◆ vpFeatureEstimationType

How to estimate the normal of a face using depth feature.

Enumerator
ROBUST_FEATURE_ESTIMATION 

Robust scheme to estimate the normal of the plane.

ROBUST_SVD_PLANE_ESTIMATION 

Use SVD and robust scheme to estimate the normal of the plane.

PCL_PLANE_ESTIMATION 

Use PCL to estimate the normal of the plane.

Definition at line 69 of file vpMbtFaceDepthNormal.h.

Constructor & Destructor Documentation

◆ vpMbtFaceDepthNormal()

BEGIN_VISP_NAMESPACE vpMbtFaceDepthNormal::vpMbtFaceDepthNormal ( )

Definition at line 59 of file vpMbtFaceDepthNormal.cpp.

◆ ~vpMbtFaceDepthNormal()

vpMbtFaceDepthNormal::~vpMbtFaceDepthNormal ( )
virtual

Definition at line 69 of file vpMbtFaceDepthNormal.cpp.

References m_listOfFaceLines.

Member Function Documentation

◆ addLine()

void vpMbtFaceDepthNormal::addLine ( vpPoint P1,
vpPoint P2,
vpMbHiddenFaces< vpMbtPolygon > *const  faces,
vpUniRand rand_gen,
int  polygon = -1,
std::string  name = "" 
)

Add a line belonging to the $ index $ the polygon to the list of lines. It is defined by its two extremities.

If the line already exists, the polygon's index is added to the list of polygon to which it belongs.

Parameters
P1: The first extremity of the line.
P2: The second extremity of the line.
faces: Pointer to vpMbHiddenFaces.
rand_gen: Random number generator used in vpMbtDistanceLine::buildFrom().
polygon: The index of the polygon to which the line belongs.
name: the optional name of the line

Definition at line 90 of file vpMbtFaceDepthNormal.cpp.

References vpMbtDistanceLine::addPolygon(), vpMbtDistanceLine::buildFrom(), vpPolygon3D::FAR_CLIPPING, vpMbtDistanceLine::getPolygon(), vpMbtDistanceLine::hiddenface, m_cam, m_clippingFlag, m_distFarClip, m_distNearClip, m_listOfFaceLines, m_polygonLines, m_useScanLine, vpPolygon3D::NEAR_CLIPPING, vpPolygon3D::NO_CLIPPING, vpMbtDistanceLine::p1, vpMbtDistanceLine::p2, samePoint(), vpMbtDistanceLine::setCameraParameters(), vpPolygon3D::setClipping(), vpPolygon3D::setFarClippingDistance(), vpMbtDistanceLine::setIndex(), vpMbtDistanceLine::setName(), vpPolygon3D::setNearClippingDistance(), and vpMbtDistanceLine::useScanLine.

Referenced by vpMbDepthNormalTracker::addFace().

◆ computeDesiredFeatures() [1/3]

◆ computeDesiredFeatures() [2/3]

◆ computeDesiredFeatures() [3/3]

◆ computeDesiredFeaturesPCL()

bool vpMbtFaceDepthNormal::computeDesiredFeaturesPCL ( const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &  point_cloud_face,
vpColVector desired_features,
vpColVector desired_normal,
vpColVector centroid_point 
)
protected

◆ computeDesiredFeaturesRobustFeatures()

void vpMbtFaceDepthNormal::computeDesiredFeaturesRobustFeatures ( const std::vector< double > &  point_cloud_face_custom,
const std::vector< double > &  point_cloud_face,
const vpHomogeneousMatrix cMo,
vpColVector desired_features,
vpColVector desired_normal,
vpColVector centroid_point 
)
protected

Definition at line 709 of file vpMbtFaceDepthNormal.cpp.

References computeNormalVisibility(), and estimateFeatures().

Referenced by computeDesiredFeatures().

◆ computeDesiredFeaturesSVD()

void vpMbtFaceDepthNormal::computeDesiredFeaturesSVD ( const std::vector< double > &  point_cloud_face,
const vpHomogeneousMatrix cMo,
vpColVector desired_features,
vpColVector desired_normal,
vpColVector centroid_point 
)
protected

◆ computeDesiredNormalAndCentroid()

void vpMbtFaceDepthNormal::computeDesiredNormalAndCentroid ( const vpHomogeneousMatrix cMo,
const vpColVector desired_normal,
const vpColVector centroid_point 
)
protected

◆ computeInteractionMatrix()

void vpMbtFaceDepthNormal::computeInteractionMatrix ( const vpHomogeneousMatrix cMo,
vpMatrix L,
vpColVector features 
)

◆ computeNormalVisibility() [1/3]

void vpMbtFaceDepthNormal::computeNormalVisibility ( double  nx,
double  ny,
double  nz,
const vpColVector centroid_point,
vpColVector face_normal 
)

◆ computeNormalVisibility() [2/3]

◆ computeNormalVisibility() [3/3]

void vpMbtFaceDepthNormal::computeNormalVisibility ( float  nx,
float  ny,
float  nz,
const pcl::PointXYZ &  centroid_point,
pcl::PointXYZ &  face_normal 
)

Definition at line 996 of file vpMbtFaceDepthNormal.cpp.

References vpColVector::dotProd(), and vpColVector::normalize().

◆ computePolygonCentroid()

bool vpMbtFaceDepthNormal::computePolygonCentroid ( const std::vector< vpPoint > &  points,
vpPoint centroid 
)
protected

◆ computeROI()

◆ computeVisibility()

void vpMbtFaceDepthNormal::computeVisibility ( )

◆ computeVisibilityDisplay()

◆ display() [1/2]

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

◆ display() [2/2]

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

◆ displayFeature() [1/2]

◆ displayFeature() [2/2]

◆ estimateFeatures()

void vpMbtFaceDepthNormal::estimateFeatures ( const std::vector< double > &  point_cloud_face,
const vpHomogeneousMatrix cMo,
vpColVector x_estimated,
std::vector< double > &  weights 
)
protected

◆ estimatePlaneEquationSVD()

void vpMbtFaceDepthNormal::estimatePlaneEquationSVD ( const std::vector< double > &  point_cloud_face,
const vpHomogeneousMatrix cMo,
vpColVector plane_equation_estimated,
vpColVector centroid 
)
protected

◆ getFeaturesForDisplay()

std::vector< std::vector< double > > vpMbtFaceDepthNormal::getFeaturesForDisplay ( const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
double  scale = 0.05 
)

◆ getModelForDisplay()

std::vector< std::vector< double > > vpMbtFaceDepthNormal::getModelForDisplay ( unsigned int  width,
unsigned int  height,
const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
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
width: Image width.
height: Image height.
cMo: Pose used to project the 3D model into the image.
cam: The camera parameters.
displayFullModel: If true, the line is displayed even if it is not

Definition at line 1801 of file vpMbtFaceDepthNormal.cpp.

References computeVisibilityDisplay(), vpMbtDistanceLine::getModelForDisplay(), vpMbtPolygon::isVisible(), m_isTrackedDepthNormalFace, m_listOfFaceLines, and m_polygon.

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

◆ isTracked()

bool vpMbtFaceDepthNormal::isTracked ( ) const
inline

Definition at line 164 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::segmentPointCloud().

◆ isVisible()

bool vpMbtFaceDepthNormal::isVisible ( ) const
inline

◆ planeIsInvalid()

bool vpMbtFaceDepthNormal::planeIsInvalid ( const vpHomogeneousMatrix cMo,
double  maxAngle 
)

Returns true when the plane is nearly parallalel to the optical axis and close to the optical center. In this case, the interaction matrix related to this face may "explode" leading to a tracking failure.

Definition at line 1045 of file vpMbtFaceDepthNormal.cpp.

References vpPlane::changeFrame(), vpPoint::changeFrame(), computePolygonCentroid(), vpColVector::frobeniusNorm(), vpPoint::get_X(), vpPoint::get_Y(), vpPoint::get_Z(), vpPlane::getD(), vpPolygon3D::getPolygonClipped(), vpHomogeneousMatrix::getTranslationVector(), m_planeCamera, m_planeObject, m_polygon, and vpForwardProjection::project().

◆ samePoint()

bool vpMbtFaceDepthNormal::samePoint ( const vpPoint P1,
const vpPoint P2 
) const
protected

Check if two vpPoints are similar.

To be similar : $ (X_1 - X_2)^2 + (Y_1 - Y_2)^2 + (Z_1 - Z_2)^2 < epsilon $.

Parameters
P1: The first point to compare
P2: The second point to compare

Definition at line 1832 of file vpMbtFaceDepthNormal.cpp.

References vpPoint::get_oX(), vpPoint::get_oY(), and vpPoint::get_oZ().

Referenced by addLine().

◆ setCameraParameters()

void vpMbtFaceDepthNormal::setCameraParameters ( const vpCameraParameters camera)

Definition at line 1845 of file vpMbtFaceDepthNormal.cpp.

References m_cam, and m_listOfFaceLines.

◆ setFaceCentroidMethod()

void vpMbtFaceDepthNormal::setFaceCentroidMethod ( const vpFaceCentroidType method)
inline

Definition at line 170 of file vpMbtFaceDepthNormal.h.

◆ setFeatureEstimationMethod()

void vpMbtFaceDepthNormal::setFeatureEstimationMethod ( const vpFeatureEstimationType method)
inline

Definition at line 172 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace().

◆ setPclPlaneEstimationMethod()

void vpMbtFaceDepthNormal::setPclPlaneEstimationMethod ( int  method)
inline

Definition at line 174 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace().

◆ setPclPlaneEstimationRansacMaxIter()

void vpMbtFaceDepthNormal::setPclPlaneEstimationRansacMaxIter ( int  maxIter)
inline

Definition at line 176 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace().

◆ setPclPlaneEstimationRansacThreshold()

void vpMbtFaceDepthNormal::setPclPlaneEstimationRansacThreshold ( double  threshold)
inline

Definition at line 178 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace().

◆ setScanLineVisibilityTest()

void vpMbtFaceDepthNormal::setScanLineVisibilityTest ( bool  v)

Definition at line 1855 of file vpMbtFaceDepthNormal.cpp.

References m_listOfFaceLines, and m_useScanLine.

◆ setTracked()

void vpMbtFaceDepthNormal::setTracked ( bool  tracked)
inline

Member Data Documentation

◆ m_cam

vpCameraParameters vpMbtFaceDepthNormal::m_cam

Camera intrinsic parameters.

Definition at line 79 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace(), addLine(), computeDesiredFeatures(), computeROI(), and setCameraParameters().

◆ m_clippingFlag

unsigned int vpMbtFaceDepthNormal::m_clippingFlag

Flags specifying which clipping to used.

Definition at line 81 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace(), addLine(), and computeROI().

◆ m_distFarClip

double vpMbtFaceDepthNormal::m_distFarClip

Distance for near clipping.

Definition at line 83 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace(), and addLine().

◆ m_distNearClip

double vpMbtFaceDepthNormal::m_distNearClip

Distance for near clipping.

Definition at line 85 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace(), and addLine().

◆ m_faceActivated

bool vpMbtFaceDepthNormal::m_faceActivated
protected

True if the face should be considered by the tracker.

Definition at line 264 of file vpMbtFaceDepthNormal.h.

Referenced by computeDesiredFeatures(), displayFeature(), and getFeaturesForDisplay().

◆ m_faceCentroidMethod

vpFaceCentroidType vpMbtFaceDepthNormal::m_faceCentroidMethod
protected

Method to compute the face centroid for the current features.

Definition at line 266 of file vpMbtFaceDepthNormal.h.

Referenced by computeNormalVisibility().

◆ m_faceDesiredCentroid

vpPoint vpMbtFaceDepthNormal::m_faceDesiredCentroid
protected

Desired centroid (computed from the sensor)

Definition at line 268 of file vpMbtFaceDepthNormal.h.

Referenced by computeDesiredNormalAndCentroid(), displayFeature(), and getFeaturesForDisplay().

◆ m_faceDesiredNormal

vpPoint vpMbtFaceDepthNormal::m_faceDesiredNormal
protected

Face (normalized) normal (computed from the sensor)

Definition at line 270 of file vpMbtFaceDepthNormal.h.

Referenced by computeDesiredNormalAndCentroid(), displayFeature(), and getFeaturesForDisplay().

◆ m_featureEstimationMethod

vpFeatureEstimationType vpMbtFaceDepthNormal::m_featureEstimationMethod
protected

Method to estimate the desired features.

Definition at line 272 of file vpMbtFaceDepthNormal.h.

Referenced by computeDesiredFeatures().

◆ m_hiddenFace

vpMbHiddenFaces<vpMbtPolygon>* vpMbtFaceDepthNormal::m_hiddenFace

Pointer to the list of faces.

Definition at line 87 of file vpMbtFaceDepthNormal.h.

Referenced by vpMbDepthNormalTracker::addFace(), computeDesiredFeatures(), and computeROI().

◆ m_isTrackedDepthNormalFace

bool vpMbtFaceDepthNormal::m_isTrackedDepthNormalFace
protected

◆ m_isVisible

bool vpMbtFaceDepthNormal::m_isVisible
protected

◆ m_listOfFaceLines

std::vector<vpMbtDistanceLine *> vpMbtFaceDepthNormal::m_listOfFaceLines
protected

◆ m_pclPlaneEstimationMethod

int vpMbtFaceDepthNormal::m_pclPlaneEstimationMethod
protected

PCL plane estimation method.

Definition at line 283 of file vpMbtFaceDepthNormal.h.

Referenced by computeDesiredFeaturesPCL().

◆ m_pclPlaneEstimationRansacMaxIter

int vpMbtFaceDepthNormal::m_pclPlaneEstimationRansacMaxIter
protected

PCL pane estimation max number of iterations.

Definition at line 285 of file vpMbtFaceDepthNormal.h.

Referenced by computeDesiredFeaturesPCL().

◆ m_pclPlaneEstimationRansacThreshold

double vpMbtFaceDepthNormal::m_pclPlaneEstimationRansacThreshold
protected

PCL plane estimation RANSAC threshold.

Definition at line 287 of file vpMbtFaceDepthNormal.h.

Referenced by computeDesiredFeaturesPCL().

◆ m_planeCamera

vpPlane vpMbtFaceDepthNormal::m_planeCamera
protected

Plane equation described in the camera frame and updated with the current pose

Definition at line 281 of file vpMbtFaceDepthNormal.h.

Referenced by computeInteractionMatrix(), displayFeature(), estimateFeatures(), estimatePlaneEquationSVD(), getFeaturesForDisplay(), and planeIsInvalid().

◆ m_planeObject

vpPlane vpMbtFaceDepthNormal::m_planeObject

◆ m_polygon

◆ m_polygonLines

std::vector<PolygonLine> vpMbtFaceDepthNormal::m_polygonLines
protected

Definition at line 289 of file vpMbtFaceDepthNormal.h.

Referenced by addLine(), and computeROI().

◆ m_useScanLine

bool vpMbtFaceDepthNormal::m_useScanLine