36 #ifndef _vpMbtFaceDepthNormal_h_
37 #define _vpMbtFaceDepthNormal_h_
41 #include <visp3/core/vpConfig.h>
42 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS)
43 #include <pcl/point_cloud.h>
44 #include <pcl/point_types.h>
47 #include <visp3/core/vpPlane.h>
48 #include <visp3/mbt/vpMbTracker.h>
49 #include <visp3/mbt/vpMbtDistanceLine.h>
51 #define DEBUG_DISPLAY_DEPTH_NORMAL 0
71 ROBUST_FEATURE_ESTIMATION = 0,
72 ROBUST_SVD_PLANE_ESTIMATION = 1,
73 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS)
74 PCL_PLANE_ESTIMATION = 2
99 int polygon = -1, std::string name =
"");
101 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS)
102 bool computeDesiredFeatures(
const vpHomogeneousMatrix &cMo,
unsigned int width,
unsigned int height,
103 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud,
104 vpColVector &desired_features,
unsigned int stepX,
unsigned int stepY
105 #
if DEBUG_DISPLAY_DEPTH_NORMAL
112 bool computeDesiredFeatures(
const vpHomogeneousMatrix &cMo,
unsigned int width,
unsigned int height,
113 const std::vector<vpColVector> &point_cloud,
vpColVector &desired_features,
114 unsigned int stepX,
unsigned int stepY
115 #
if DEBUG_DISPLAY_DEPTH_NORMAL
121 bool computeDesiredFeatures(
const vpHomogeneousMatrix &cMo,
unsigned int width,
unsigned int height,
123 unsigned int stepX,
unsigned int stepY
124 #
if DEBUG_DISPLAY_DEPTH_NORMAL
133 void computeVisibility();
134 void computeVisibilityDisplay();
138 void computeNormalVisibility(
double nx,
double ny,
double nz,
const vpColVector ¢roid_point,
140 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS)
141 void computeNormalVisibility(
float nx,
float ny,
float nz,
const pcl::PointXYZ ¢roid_point,
142 pcl::PointXYZ &face_normal);
144 void computeNormalVisibility(
double nx,
double ny,
double nz,
const vpHomogeneousMatrix &cMo,
148 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
150 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
153 double scale = 0.05,
unsigned int thickness = 1);
155 double scale = 0.05,
unsigned int thickness = 1);
158 double scale = 0.05);
160 std::vector<std::vector<double> > getModelForDisplay(
unsigned int width,
unsigned int height,
162 bool displayFullModel =
false);
164 inline bool isTracked()
const {
return m_isTrackedDepthNormalFace; }
180 m_pclPlaneEstimationRansacThreshold = threshold;
183 void setScanLineVisibilityTest(
bool v);
185 inline void setTracked(
bool tracked) { m_isTrackedDepthNormalFace = tracked; }
202 PolygonLine() : m_p1(nullptr), m_p2(nullptr), m_poly(), m_imPt1(), m_imPt2() { }
204 PolygonLine(
const PolygonLine &polyLine)
205 : m_p1(nullptr), m_p2(nullptr), m_poly(polyLine.m_poly), m_imPt1(polyLine.m_imPt1), m_imPt2(polyLine.m_imPt2)
211 PolygonLine &operator=(PolygonLine other)
218 void swap(PolygonLine &first, PolygonLine &second)
221 swap(first.m_p1, second.m_p1);
222 swap(first.m_p2, second.m_p2);
223 swap(first.m_poly, second.m_poly);
224 swap(first.m_imPt1, second.m_imPt1);
225 swap(first.m_imPt2, second.m_imPt2);
229 template <
class T>
class Mat33
234 Mat33() : data(9) { }
236 inline T operator[](
const size_t i)
const {
return data[i]; }
238 inline T &operator[](
const size_t i) {
return data[i]; }
240 Mat33 inverse()
const
243 T det = data[0] * (data[4] * data[8] - data[7] * data[5]) - data[1] * (data[3] * data[8] - data[5] * data[6]) +
244 data[2] * (data[3] * data[7] - data[4] * data[6]);
248 minv[0] = (data[4] * data[8] - data[7] * data[5]) * invdet;
249 minv[1] = (data[2] * data[7] - data[1] * data[8]) * invdet;
250 minv[2] = (data[1] * data[5] - data[2] * data[4]) * invdet;
251 minv[3] = (data[5] * data[6] - data[3] * data[8]) * invdet;
252 minv[4] = (data[0] * data[8] - data[2] * data[6]) * invdet;
253 minv[5] = (data[3] * data[2] - data[0] * data[5]) * invdet;
254 minv[6] = (data[3] * data[7] - data[6] * data[4]) * invdet;
255 minv[7] = (data[6] * data[1] - data[0] * data[7]) * invdet;
256 minv[8] = (data[0] * data[4] - data[3] * data[1]) * invdet;
291 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS)
292 bool computeDesiredFeaturesPCL(
const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud_face,
296 void computeDesiredFeaturesRobustFeatures(
const std::vector<double> &point_cloud_face_custom,
300 void computeDesiredFeaturesSVD(
const std::vector<double> &point_cloud_face,
const vpHomogeneousMatrix &cMo,
306 bool computePolygonCentroid(
const std::vector<vpPoint> &points,
vpPoint ¢roid);
309 std::vector<vpImagePoint> &roiPts
310 #
if DEBUG_DISPLAY_DEPTH_NORMAL
312 std::vector<std::vector<vpImagePoint> > &roiPts_vec
316 void estimateFeatures(
const std::vector<double> &point_cloud_face,
const vpHomogeneousMatrix &cMo,
317 vpColVector &x_estimated, std::vector<double> &weights);
319 void estimatePlaneEquationSVD(
const std::vector<double> &point_cloud_face,
const vpHomogeneousMatrix &cMo,
326 #ifdef VISP_HAVE_NLOHMANN_JSON
327 #include VISP_NLOHMANN_JSON(json.hpp)
328 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS)
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Class to define RGB colors available for display functionalities.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Implementation of a matrix and operations on matrices.
double m_pclPlaneEstimationRansacThreshold
PCL plane estimation RANSAC threshold.
int m_pclPlaneEstimationMethod
PCL plane estimation method.
double m_distNearClip
Distance for near clipping.
double m_distFarClip
Distance for near clipping.
vpMbHiddenFaces< vpMbtPolygon > * m_hiddenFace
Pointer to the list of faces.
std::vector< vpMbtDistanceLine * > m_listOfFaceLines
void setPclPlaneEstimationMethod(int method)
bool m_isTrackedDepthNormalFace
vpFeatureEstimationType m_featureEstimationMethod
Method to estimate the desired features.
void setPclPlaneEstimationRansacThreshold(double threshold)
vpMbtPolygon * m_polygon
Polygon defining the face.
vpPoint m_faceDesiredCentroid
Desired centroid (computed from the sensor)
vpCameraParameters m_cam
Camera intrinsic parameters.
@ 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.
vpPlane m_planeObject
Plane equation described in the object frame.
bool m_faceActivated
True if the face should be considered by the tracker.
@ GEOMETRIC_CENTROID
Compute the geometric centroid.
vpFaceCentroidType m_faceCentroidMethod
Method to compute the face centroid for the current features.
int m_pclPlaneEstimationRansacMaxIter
PCL pane estimation max number of iterations.
unsigned int m_clippingFlag
Flags specifying which clipping to used.
void setTracked(bool tracked)
vpPoint m_faceDesiredNormal
Face (normalized) normal (computed from the sensor)
void setFeatureEstimationMethod(const vpFeatureEstimationType &method)
std::vector< PolygonLine > m_polygonLines
void setFaceCentroidMethod(const vpFaceCentroidType &method)
void setPclPlaneEstimationRansacMaxIter(int maxIter)
bool m_useScanLine
Scan line visibility.
Implementation of a polygon of the model used by the model-based tracker.
bool isvisible
flag to specify whether the face is visible or not
This class defines the container for a plane geometrical structure.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
vpPoint * p
corners in the object frame
Class for generating random numbers with uniform probability density.