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> 84 EDGE_TRACKER = 1 << 0,
85 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 88 DEPTH_NORMAL_TRACKER = 1 << 2,
89 DEPTH_DENSE_TRACKER = 1 << 3
93 vpMbGenericTracker(
const unsigned int nbCameras,
const int trackerType = EDGE_TRACKER);
95 vpMbGenericTracker(
const std::vector<std::string> &cameraNames,
const std::vector<int> &trackerTypes);
103 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
105 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
110 const bool displayFullModel =
false);
113 const vpColor &color,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
116 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
117 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
118 const unsigned int thickness = 1,
const bool displayFullModel =
false);
120 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
121 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
122 const unsigned int thickness = 1,
const bool displayFullModel =
false);
124 virtual std::vector<std::string> getCameraNames()
const;
128 virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters)
const;
130 virtual std::map<std::string, int> getCameraTrackerTypes()
const;
133 virtual void getClipping(
unsigned int &clippingFlag1,
unsigned int &clippingFlag2)
const;
134 virtual void getClipping(std::map<std::string, unsigned int> &mapOfClippingFlags)
const;
141 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 142 virtual std::list<vpMbtDistanceCircle *> &getFeaturesCircle();
143 virtual std::list<vpMbtDistanceKltCylinder *> &getFeaturesKltCylinder();
144 virtual std::list<vpMbtDistanceKltPoints *> &getFeaturesKlt();
147 virtual double getGoodMovingEdgesRatioThreshold()
const;
149 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 150 virtual std::vector<vpImagePoint> getKltImagePoints()
const;
151 virtual std::map<int, vpImagePoint> getKltImagePointsWithId()
const;
153 virtual unsigned int getKltMaskBorder()
const;
154 virtual int getKltNbPoints()
const;
158 virtual void getKltOpencv(std::map<std::string, vpKltOpencv> &mapOfKlts)
const;
160 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408) 161 virtual std::vector<cv::Point2f> getKltPoints()
const;
164 virtual double getKltThresholdAcceptation()
const;
167 virtual void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList,
const unsigned int level = 0)
const;
168 virtual void getLcircle(
const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
169 const unsigned int level = 0)
const;
170 virtual void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList,
const unsigned int level = 0)
const;
171 virtual void getLcylinder(
const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
172 const unsigned int level = 0)
const;
173 virtual void getLline(std::list<vpMbtDistanceLine *> &linesList,
const unsigned int level = 0)
const;
174 virtual void getLline(
const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
175 const unsigned int level = 0)
const;
177 virtual vpMe getMovingEdge()
const;
178 virtual void getMovingEdge(
vpMe &me1,
vpMe &me2)
const;
179 virtual void getMovingEdge(std::map<std::string, vpMe> &mapOfMovingEdges)
const;
181 virtual unsigned int getNbPoints(
const unsigned int level = 0)
const;
182 virtual void getNbPoints(std::map<std::string, unsigned int> &mapOfNbPoints,
const unsigned int level = 0)
const;
185 virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons)
const;
190 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
191 getPolygonFaces(
const bool orderPolygons =
true,
const bool useVisibility =
true,
const bool clipPolygon =
false);
192 virtual void getPolygonFaces(std::map<std::string, std::vector<vpPolygon> > &mapOfPolygons,
193 std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
194 const bool orderPolygons =
true,
const bool useVisibility =
true,
195 const bool clipPolygon =
false);
199 virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
const;
203 virtual int getTrackerType()
const;
207 #ifdef VISP_HAVE_MODULE_GUI 210 const std::string &initFile1,
const std::string &initFile2,
const bool displayHelp =
false,
213 const std::map<std::string, std::string> &mapOfInitFiles,
const bool displayHelp =
false,
214 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
219 const std::string &initFile1,
const std::string &initFile2);
221 const std::map<std::string, std::string> &mapOfInitPoints);
225 const std::string &initFile1,
const std::string &initFile2);
227 const std::map<std::string, std::string> &mapOfInitPoses);
232 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
235 virtual void loadConfigFile(
const std::string &configFile1,
const std::string &configFile2);
236 virtual void loadConfigFile(
const std::map<std::string, std::string> &mapOfConfigFiles);
239 virtual void loadModel(
const std::string &modelFile1,
const std::string &modelFile2,
const bool verbose =
false,
241 virtual void loadModel(
const std::map<std::string, std::string> &mapOfModelFiles,
const bool verbose =
false,
242 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
248 const std::string &cad_name1,
const std::string &cad_name2,
const vpHomogeneousMatrix &c1Mo,
252 const std::map<std::string, std::string> &mapOfModelFiles,
253 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
254 const bool verbose =
false,
255 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
261 virtual void setAngleAppear(
const std::map<std::string, double> &mapOfAngles);
265 virtual void setAngleDisappear(
const std::map<std::string, double> &mapOfAngles);
269 virtual void setCameraParameters(
const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
271 virtual void setCameraTransformationMatrix(
const std::string &cameraName,
274 setCameraTransformationMatrix(
const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
276 virtual void setClipping(
const unsigned int &flags);
277 virtual void setClipping(
const unsigned int &flags1,
const unsigned int &flags2);
278 virtual void setClipping(
const std::map<std::string, unsigned int> &mapOfClippingFlags);
280 virtual void setDepthDenseFilteringMaxDistance(
const double maxDistance);
281 virtual void setDepthDenseFilteringMethod(
const int method);
282 virtual void setDepthDenseFilteringMinDistance(
const double minDistance);
283 virtual void setDepthDenseFilteringOccupancyRatio(
const double occupancyRatio);
284 virtual void setDepthDenseSamplingStep(
const unsigned int stepX,
const unsigned int stepY);
288 virtual void setDepthNormalPclPlaneEstimationMethod(
const int method);
289 virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(
const int maxIter);
290 virtual void setDepthNormalPclPlaneEstimationRansacThreshold(
const double thresold);
291 virtual void setDepthNormalSamplingStep(
const unsigned int stepX,
const unsigned int stepY);
299 virtual void setFeatureFactors(
const std::map<vpTrackerType, double> &mapOfFeatureFactors);
301 virtual void setGoodMovingEdgesRatioThreshold(
const double threshold);
303 #ifdef VISP_HAVE_OGRE 308 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 309 virtual void setKltMaskBorder(
const unsigned int &e);
310 virtual void setKltMaskBorder(
const unsigned int &e1,
const unsigned int &e2);
311 virtual void setKltMaskBorder(
const std::map<std::string, unsigned int> &mapOfErosions);
315 virtual void setKltOpencv(
const std::map<std::string, vpKltOpencv> &mapOfKlts);
317 virtual void setKltThresholdAcceptation(
const double th);
321 virtual void setLod(
const bool useLod,
const std::string &name =
"");
328 virtual void setMovingEdge(
const vpMe &me);
329 virtual void setMovingEdge(
const vpMe &me1,
const vpMe &me2);
330 virtual void setMovingEdge(
const std::map<std::string, vpMe> &mapOfMe);
345 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
353 virtual void setReferenceCameraName(
const std::string &referenceCameraName);
357 virtual void setTrackerType(
const int type);
358 virtual void setTrackerType(
const std::map<std::string, int> &mapOfTrackerTypes);
360 virtual void setUseDepthDenseTracking(
const std::string &name,
const bool &useDepthDenseTracking);
361 virtual void setUseDepthNormalTracking(
const std::string &name,
const bool &useDepthNormalTracking);
362 virtual void setUseEdgeTracking(
const std::string &name,
const bool &useEdgeTracking);
363 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 364 virtual void setUseKltTracking(
const std::string &name,
const bool &useKltTracking);
374 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
377 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
378 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
379 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
382 virtual void computeProjectionError();
390 std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
395 const int idFace = 0,
const std::string &name =
"");
398 const std::string &name =
"");
406 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
409 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
410 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
411 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
415 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 436 explicit TrackerWrapper(
const int trackerType);
438 virtual ~TrackerWrapper();
444 virtual inline int getTrackerType()
const {
return m_trackerType; }
447 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
449 const vpColor &col,
const unsigned int thickness = 1,
const bool displayFullModel =
false);
463 virtual void setClipping(
const unsigned int &flags);
486 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud =
nullptr);
500 const int idFace = 0,
const std::string &name =
"");
503 const std::string &name =
"");
512 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud =
nullptr);
514 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud =
nullptr);
516 virtual void postTracking(
const vpImage<unsigned char> *
const ptr_I = NULL,
const unsigned int pointcloud_width = 0,
517 const unsigned int pointcloud_height = 0);
519 const std::vector<vpColVector> *
const point_cloud = NULL,
520 const unsigned int pointcloud_width = 0,
const unsigned int pointcloud_height = 0);
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 unsigned int getClipping() const
virtual void setAngleDisappear(const double &a)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void resetTracker()
virtual void track(const vpImage< unsigned char > &)
virtual void loadConfigFile(const std::string &configFile)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
virtual void loadModel(const std::string &modelFile, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
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()
virtual void setMask(const vpImage< bool > &mask)
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)
Real-time 6D object pose tracking using its CAD model.
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 vpColVector getRobustWeights() const
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 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 vpHomogeneousMatrix getPose() const
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 reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void getCameraParameters(vpCameraParameters &camera) const
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)
virtual void setProjectionErrorDisplay(const bool display)
Model based tracker using only KLT.
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 void setCameraParameters(const vpCameraParameters &camera)
virtual void preTracking(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, std::map< std::string, pcl::PointCloud< pcl::PointXYZ >::ConstPtr > &mapOfPointClouds)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setOgreVisibilityTest(const bool &v)
virtual double computeCurrentProjectionError(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo, const vpCameraParameters &_cam)
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 setProjectionErrorDisplayArrowLength(const unsigned int length)
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 unsigned int getNbPolygon() const
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
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 vpColVector getError() const
virtual void setProjectionErrorDisplayArrowThickness(const unsigned int thickness)
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages)
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 int getTrackerType() const
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)