Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpMbtFaceDepthDense.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Manage depth dense features for a particular face.
32 */
33
34#ifndef VP_MBT_FACE_DEPTH_DENSE_H
35#define VP_MBT_FACE_DEPTH_DENSE_H
36
37#include <iostream>
38
39#include <visp3/core/vpConfig.h>
40#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
41#include <pcl/point_cloud.h>
42#include <pcl/point_types.h>
43#endif
44
45#include <visp3/core/vpPlane.h>
46#include <visp3/mbt/vpMbTracker.h>
47#include <visp3/mbt/vpMbtDistanceLine.h>
48
49#define DEBUG_DISPLAY_DEPTH_DENSE 0
50
68 class VISP_EXPORT vpMbtFaceDepthDense
69{
70public:
82
86 unsigned int m_clippingFlag;
99
102 virtual ~vpMbtFaceDepthDense();
104
105 void addLine(vpPoint &p1, vpPoint &p2, vpMbHiddenFaces<vpMbtPolygon> *const faces, vpUniRand &rand_gen,
106 int polygon = -1, std::string name = "");
107
108#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
110 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud, unsigned int stepX,
111 unsigned int stepY
112#if DEBUG_DISPLAY_DEPTH_DENSE
113 ,
114 vpImage<unsigned char> &debugImage, std::vector<std::vector<vpImagePoint> > &roiPts_vec
115#endif
116 ,
117 const vpImage<bool> *mask = nullptr);
118#endif
119 bool computeDesiredFeatures(const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height,
120 const std::vector<vpColVector> &point_cloud, unsigned int stepX, unsigned int stepY
121#if DEBUG_DISPLAY_DEPTH_DENSE
122 ,
123 vpImage<unsigned char> &debugImage, std::vector<std::vector<vpImagePoint> > &roiPts_vec
124#endif
125 ,
126 const vpImage<bool> *mask = nullptr);
127 bool computeDesiredFeatures(const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height,
128 const vpMatrix &point_cloud, unsigned int stepX, unsigned int stepY
129#if DEBUG_DISPLAY_DEPTH_DENSE
130 ,
131 vpImage<unsigned char> &debugImage, std::vector<std::vector<vpImagePoint> > &roiPts_vec
132#endif
133 ,
134 const vpImage<bool> *mask = nullptr);
135
137
138 void computeVisibility();
140
141 void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
142 const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
143 void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
144 const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
145
147 double scale = 0.05, unsigned int thickness = 1);
148 void displayFeature(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
149 double scale = 0.05, unsigned int thickness = 1);
150
151 std::vector<std::vector<double> > getModelForDisplay(unsigned int width, unsigned int height,
152 const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
153 bool displayFullModel = false);
154
155 inline unsigned int getNbFeatures() const { return static_cast<unsigned int>(m_pointCloudFace.size() / 3); }
156
157 inline bool isTracked() const { return m_isTrackedDepthDenseFace; }
158
159 inline bool isVisible() const { return m_polygon->isvisible; }
160
161 void setCameraParameters(const vpCameraParameters &camera);
162
163 void setScanLineVisibilityTest(bool v);
164
165 inline void setDepthDenseFilteringMaxDistance(double maxDistance) { m_depthDenseFilteringMaxDist = maxDistance; }
166
167 inline void setDepthDenseFilteringMethod(int method) { m_depthDenseFilteringMethod = method; }
168
169 inline void setDepthDenseFilteringMinDistance(double minDistance) { m_depthDenseFilteringMinDist = minDistance; }
170
171 inline void setDepthDenseFilteringOccupancyRatio(double occupancyRatio)
172 {
173 if (occupancyRatio < 0.0 || occupancyRatio > 1.0) {
174 std::cerr << "occupancyRatio < 0.0 || occupancyRatio > 1.0" << std::endl;
175 }
176 else {
178 }
179 }
180
181 inline void setTracked(bool tracked) { m_isTrackedDepthDenseFace = tracked; }
182
183private:
184 class PolygonLine
185 {
186 public:
188 vpPoint *m_p1;
190 vpPoint *m_p2;
192 vpMbtPolygon m_poly;
194 vpImagePoint m_imPt1;
196 vpImagePoint m_imPt2;
197
198 PolygonLine() : m_p1(nullptr), m_p2(nullptr), m_poly(), m_imPt1(), m_imPt2() { }
199
200 PolygonLine(const PolygonLine &polyLine)
201 : m_p1(nullptr), m_p2(nullptr), m_poly(polyLine.m_poly), m_imPt1(polyLine.m_imPt1), m_imPt2(polyLine.m_imPt2)
202 {
203 m_p1 = &m_poly.p[0];
204 m_p2 = &m_poly.p[1];
205 }
206
207 PolygonLine &operator=(PolygonLine other)
208 {
209 swap(*this, other);
210
211 return *this;
212 }
213
214 void swap(PolygonLine &first, PolygonLine &second)
215 {
216 using std::swap;
217 swap(first.m_p1, second.m_p1);
218 swap(first.m_p2, second.m_p2);
219 swap(first.m_poly, second.m_poly);
220 swap(first.m_imPt1, second.m_imPt1);
221 swap(first.m_imPt2, second.m_imPt2);
222 }
223 };
224
225protected:
238 std::vector<vpMbtDistanceLine *> m_listOfFaceLines;
243 std::vector<double> m_pointCloudFace;
245 std::vector<PolygonLine> m_polygonLines;
246
247protected:
248 void computeROI(const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height,
249 std::vector<vpImagePoint> &roiPts
250#if DEBUG_DISPLAY_DEPTH_DENSE
251 ,
252 std::vector<std::vector<vpImagePoint> > &roiPts_vec
253#endif
254 ,
255 double &distanceToFace);
256
257 bool samePoint(const vpPoint &P1, const vpPoint &P2) const;
258};
259END_VISP_NAMESPACE
260#endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
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 ...
Definition of the vpImage class member functions.
Definition vpImage.h:131
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
Implementation of the polygons management for the model-based trackers.
double m_depthDenseFilteringMinDist
Minimum distance threshold.
vpMbHiddenFaces< vpMbtPolygon > * m_hiddenFace
Pointer to the list of faces.
bool m_isVisible
Visibility flag.
double m_distFarClip
Distance for near clipping.
std::vector< double > m_pointCloudFace
List of depth points inside the face.
vpPlane m_planeObject
Plane equation described in the object frame.
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)
void computeROI(const vpHomogeneousMatrix &cMo, unsigned int width, unsigned int height, std::vector< vpImagePoint > &roiPts, double &distanceToFace)
void setDepthDenseFilteringMethod(int method)
unsigned int getNbFeatures() const
void setTracked(bool tracked)
bool samePoint(const vpPoint &P1, const vpPoint &P2) const
void setDepthDenseFilteringMinDistance(double minDistance)
void computeInteractionMatrixAndResidu(const vpHomogeneousMatrix &cMo, vpMatrix &L, vpColVector &error)
vpMbtPolygon * m_polygon
Polygon defining the face.
bool m_useScanLine
Scan line visibility.
bool m_isTrackedDepthDenseFace
Flag to define if the face should be tracked or not.
double m_depthDenseFilteringMaxDist
Maximum distance threshold.
vpMbtFaceDepthDense & operator=(const vpMbtFaceDepthDense &mbt_face)
void setDepthDenseFilteringMaxDistance(double maxDistance)
bool computeDesiredFeatures(const vpHomogeneousMatrix &cMo, const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &point_cloud, unsigned int stepX, unsigned int stepY, const vpImage< bool > *mask=nullptr)
std::vector< PolygonLine > m_polygonLines
Polygon lines used for scan-line visibility.
int m_depthDenseFilteringMethod
Method to use to consider or not the face.
@ NO_FILTERING
Face is used if visible.
unsigned int m_clippingFlag
Flags specifying which clipping to used.
std::vector< vpMbtDistanceLine * > m_listOfFaceLines
void setDepthDenseFilteringOccupancyRatio(double occupancyRatio)
vpCameraParameters m_cam
Camera intrinsic parameters.
double m_depthDenseFilteringOccupancyRatio
Ratio between available depth points and theoretical number of points.
double m_distNearClip
Distance for near clipping.
void displayFeature(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double scale=0.05, unsigned int thickness=1)
void addLine(vpPoint &p1, vpPoint &p2, vpMbHiddenFaces< vpMbtPolygon > *const faces, vpUniRand &rand_gen, int polygon=-1, std::string name="")
Implementation of a polygon of the model used by the model-based tracker.
This class defines the container for a plane geometrical structure.
Definition vpPlane.h:56
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition vpPoint.h:79
vpPoint * p
corners in the object frame
Definition vpPolygon3D.h:79
Class for generating random numbers with uniform probability density.
Definition vpUniRand.h:127