40 #ifndef __vpMbGenericTracker_h_ 41 #define __vpMbGenericTracker_h_ 43 #include <visp3/mbt/vpMbDepthDenseTracker.h> 44 #include <visp3/mbt/vpMbDepthNormalTracker.h> 45 #include <visp3/mbt/vpMbEdgeTracker.h> 46 #include <visp3/mbt/vpMbKltTracker.h> 52 EDGE_TRACKER = 1 << 0,
53 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 56 DEPTH_NORMAL_TRACKER = 1 << 2,
57 DEPTH_DENSE_TRACKER = 1 << 3
61 vpMbGenericTracker(
const unsigned int nbCameras,
const int trackerType = EDGE_TRACKER);
63 vpMbGenericTracker(
const std::vector<std::string> &cameraNames,
const std::vector<int> &trackerTypes);
68 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
70 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
75 const bool displayFullModel =
false);
78 const vpColor &color,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
81 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
82 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
83 const unsigned int thickness = 1,
const bool displayFullModel =
false);
85 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
86 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
87 const unsigned int thickness = 1,
const bool displayFullModel =
false);
89 virtual std::vector<std::string> getCameraNames()
const;
93 virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters)
const;
95 virtual std::map<std::string, int> getCameraTrackerTypes()
const;
98 virtual void getClipping(
unsigned int &clippingFlag1,
unsigned int &clippingFlag2)
const;
99 virtual void getClipping(std::map<std::string, unsigned int> &mapOfClippingFlags)
const;
106 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 107 virtual std::list<vpMbtDistanceCircle *> &getFeaturesCircle();
108 virtual std::list<vpMbtDistanceKltCylinder *> &getFeaturesKltCylinder();
109 virtual std::list<vpMbtDistanceKltPoints *> &getFeaturesKlt();
112 virtual double getGoodMovingEdgesRatioThreshold()
const;
114 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 115 virtual std::vector<vpImagePoint> getKltImagePoints()
const;
116 virtual std::map<int, vpImagePoint> getKltImagePointsWithId()
const;
118 virtual unsigned int getKltMaskBorder()
const;
119 virtual int getKltNbPoints()
const;
123 virtual void getKltOpencv(std::map<std::string, vpKltOpencv> &mapOfKlts)
const;
125 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408) 126 virtual std::vector<cv::Point2f> getKltPoints()
const;
129 virtual double getKltThresholdAcceptation()
const;
132 virtual void getLcircle(
const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
133 const unsigned int level = 0)
const;
134 virtual void getLcylinder(
const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
135 const unsigned int level = 0)
const;
136 virtual void getLline(
const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
137 const unsigned int level = 0)
const;
139 virtual vpMe getMovingEdge()
const;
140 virtual void getMovingEdge(
vpMe &me1,
vpMe &me2)
const;
141 virtual void getMovingEdge(std::map<std::string, vpMe> &mapOfMovingEdges)
const;
143 virtual unsigned int getNbPoints(
const unsigned int level = 0)
const;
144 virtual void getNbPoints(std::map<std::string, unsigned int> &mapOfNbPoints,
const unsigned int level = 0)
const;
147 virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons)
const;
152 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
153 getPolygonFaces(
const bool orderPolygons =
true,
const bool useVisibility =
true,
const bool clipPolygon =
false);
154 virtual void getPolygonFaces(std::map<std::string, std::vector<vpPolygon> > &mapOfPolygons,
155 std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
156 const bool orderPolygons =
true,
const bool useVisibility =
true,
157 const bool clipPolygon =
false);
161 virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
const;
167 #ifdef VISP_HAVE_MODULE_GUI 170 const std::string &initFile1,
const std::string &initFile2,
const bool displayHelp =
false);
172 const std::map<std::string, std::string> &mapOfInitFiles,
const bool displayHelp =
false);
177 const std::string &initFile1,
const std::string &initFile2);
179 const std::map<std::string, std::string> &mapOfInitPoints);
183 const std::string &initFile1,
const std::string &initFile2);
185 const std::map<std::string, std::string> &mapOfInitPoses);
190 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
193 virtual void loadConfigFile(
const std::string &configFile1,
const std::string &configFile2);
194 virtual void loadConfigFile(
const std::map<std::string, std::string> &mapOfConfigFiles);
197 virtual void loadModel(
const std::string &modelFile,
const bool verbose =
false);
198 virtual void loadModel(
const std::string &modelFile1,
const std::string &modelFile2,
const bool verbose =
false);
199 virtual void loadModel(
const std::map<std::string, std::string> &mapOfModelFiles,
const bool verbose =
false);
204 const std::string &cad_name1,
const std::string &cad_name2,
const vpHomogeneousMatrix &c1Mo,
207 const std::map<std::string, std::string> &mapOfModelFiles,
208 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
209 const bool verbose =
false);
215 virtual void setAngleAppear(
const std::map<std::string, double> &mapOfAngles);
219 virtual void setAngleDisappear(
const std::map<std::string, double> &mapOfAngles);
223 virtual void setCameraParameters(
const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
225 virtual void setCameraTransformationMatrix(
const std::string &cameraName,
228 setCameraTransformationMatrix(
const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
230 virtual void setClipping(
const unsigned int &flags);
231 virtual void setClipping(
const unsigned int &flags1,
const unsigned int &flags2);
232 virtual void setClipping(
const std::map<std::string, unsigned int> &mapOfClippingFlags);
234 virtual void setDepthDenseFilteringMaxDistance(
const double maxDistance);
235 virtual void setDepthDenseFilteringMethod(
const int method);
236 virtual void setDepthDenseFilteringMinDistance(
const double minDistance);
237 virtual void setDepthDenseFilteringOccupancyRatio(
const double occupancyRatio);
238 virtual void setDepthDenseSamplingStep(
const unsigned int stepX,
const unsigned int stepY);
242 virtual void setDepthNormalPclPlaneEstimationMethod(
const int method);
243 virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(
const int maxIter);
244 virtual void setDepthNormalPclPlaneEstimationRansacThreshold(
const double thresold);
245 virtual void setDepthNormalSamplingStep(
const unsigned int stepX,
const unsigned int stepY);
253 virtual void setFeatureFactors(
const std::map<vpTrackerType, double> &mapOfFeatureFactors);
255 virtual void setGoodMovingEdgesRatioThreshold(
const double threshold);
257 #ifdef VISP_HAVE_OGRE 262 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 263 virtual void setKltMaskBorder(
const unsigned int &e);
264 virtual void setKltMaskBorder(
const unsigned int &e1,
const unsigned int &e2);
265 virtual void setKltMaskBorder(
const std::map<std::string, unsigned int> &mapOfErosions);
269 virtual void setKltOpencv(
const std::map<std::string, vpKltOpencv> &mapOfKlts);
271 virtual void setKltThresholdAcceptation(
const double th);
275 virtual void setLod(
const bool useLod,
const std::string &name =
"");
280 virtual void setMovingEdge(
const vpMe &me);
281 virtual void setMovingEdge(
const vpMe &me1,
const vpMe &me2);
282 virtual void setMovingEdge(
const std::map<std::string, vpMe> &mapOfMe);
297 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
301 virtual void setReferenceCameraName(
const std::string &referenceCameraName);
305 virtual void setTrackerType(
const int type);
306 virtual void setTrackerType(
const std::map<std::string, int> &mapOfTrackerTypes);
308 virtual void setUseEdgeTracking(
const std::string &name,
const bool &useEdgeTracking);
309 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 310 virtual void setUseKltTracking(
const std::string &name,
const bool &useKltTracking);
320 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
323 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
324 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
325 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
328 virtual void computeProjectionError();
336 std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
341 const int idFace = 0,
const std::string &name =
"");
344 const std::string &name =
"");
352 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
355 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
356 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
357 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
361 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 382 explicit TrackerWrapper(
const int trackerType);
384 virtual ~TrackerWrapper();
390 virtual inline int getTrackerType()
const {
return m_trackerType; }
393 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
395 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
408 virtual void setClipping(
const unsigned int &flags);
431 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud =
nullptr);
445 const int idFace = 0,
const std::string &name =
"");
448 const std::string &name =
"");
457 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud =
nullptr);
459 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud =
nullptr);
461 virtual void postTracking(
const vpImage<unsigned char> *
const ptr_I = NULL,
const unsigned int pointcloud_width = 0,
462 const unsigned int pointcloud_height = 0);
464 const std::vector<vpColVector> *
const point_cloud = NULL,
465 const unsigned int pointcloud_width = 0,
const unsigned int pointcloud_height = 0);
virtual unsigned int getClipping() const
virtual void setDisplayFeatures(const bool displayF)
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
virtual void loadConfigFile(const std::string &configFile)
Implementation of a matrix and operations on matrices.
virtual void track(const vpImage< unsigned char > &I)
virtual void track(const vpImage< unsigned char > &I)=0
virtual void computeVVSInteractionMatrixAndResidu()=0
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")
virtual void computeVVSInit()=0
vpColVector m_w
Robust weights.
virtual void setAngleDisappear(const double &a)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
virtual void resetTracker()
virtual void track(const vpImage< unsigned char > &)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
Class to define colors available for display functionnalities.
vpHomogeneousMatrix cMo
The current pose.
virtual void setClipping(const unsigned int &flags)
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")=0
virtual void track(const vpImage< unsigned char > &)
virtual void computeVVSInit()
Make the complete tracking of an object by using its CAD model.
virtual void computeVVSInteractionMatrixAndResidu()
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
std::map< vpTrackerType, double > m_mapOfFeatureFactors
Ponderation between each feature type in the VVS stage.
virtual void resetTracker()=0
std::map< std::string, TrackerWrapper * > m_mapOfTrackers
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages)
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
virtual void init(const vpImage< unsigned char > &I)=0
vpMatrix m_L
Interaction matrix.
virtual vpHomogeneousMatrix getPose() const
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)=0
virtual void initFaceFromLines(vpMbtPolygon &polygon)
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
vpColVector m_weightedError
Weighted error.
Implementation of a polygon of the model used by the model-based tracker.
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void setProjectionErrorComputation(const bool &flag)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
Generic class defining intrinsic camera parameters.
Main methods for a model-based tracker.
virtual void computeVVSInteractionMatrixAndResidu()
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
virtual void setAngleAppear(const double &a)
Model based tracker using only KLT.
virtual void loadConfigFile(const std::string &configFile)=0
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false)
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void computeVVSWeights()
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
virtual void testTracking()
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void setNearClippingDistance(const double &dist)
virtual vpColVector getError() const
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void setScanLineVisibilityTest(const bool &v)
virtual vpColVector getRobustWeights() const
virtual void setOgreVisibilityTest(const bool &v)
virtual void loadModel(const char *modelFile, const bool verbose=false)
virtual void getCameraParameters(vpCameraParameters &camera) const
virtual unsigned int getNbPolygon() const
vpColVector m_error
(s - s*)
virtual void init(const vpImage< unsigned char > &I)
Implementation of column vector and the associated operations.
virtual void setOgreVisibilityTest(const bool &v)
std::string m_referenceCameraName
Name of the reference camera.
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
virtual void setFarClippingDistance(const double &dist)
virtual void testTracking()=0
virtual void preTracking(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, std::map< std::string, pcl::PointCloud< pcl::PointXYZ >::ConstPtr > &mapOfPointClouds)
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual vpMbtPolygon * getPolygon(const unsigned int index)
virtual void setTrackerType(const int type)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setClipping(const unsigned int &flags)
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void setFarClippingDistance(const double &dist)
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(const bool orderPolygons=true, const bool useVisibility=true, const bool clipPolygon=false)
double m_thresholdOutlier
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")=0
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setLod(const bool useLod, const std::string &name="")
virtual void setNearClippingDistance(const double &dist)