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
95 vpMbGenericTracker(
const std::vector<std::string> &cameraNames,
const std::vector<int> &trackerTypes);
105 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
107 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
112 bool displayFullModel =
false);
115 const vpColor &color,
unsigned int thickness = 1,
bool displayFullModel =
false);
118 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
119 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
120 unsigned int thickness = 1,
bool displayFullModel =
false);
122 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
123 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
const vpColor &col,
124 unsigned int thickness = 1,
bool displayFullModel =
false);
126 virtual std::vector<std::string> getCameraNames()
const;
131 virtual void getCameraParameters(std::map<std::string, vpCameraParameters> &mapOfCameraParameters)
const;
133 virtual std::map<std::string, int> getCameraTrackerTypes()
const;
136 virtual void getClipping(
unsigned int &clippingFlag1,
unsigned int &clippingFlag2)
const;
137 virtual void getClipping(std::map<std::string, unsigned int> &mapOfClippingFlags)
const;
144 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 145 virtual std::list<vpMbtDistanceCircle *> &getFeaturesCircle();
146 virtual std::list<vpMbtDistanceKltCylinder *> &getFeaturesKltCylinder();
147 virtual std::list<vpMbtDistanceKltPoints *> &getFeaturesKlt();
150 virtual std::vector<std::vector<double> > getFeaturesForDisplay();
151 virtual void getFeaturesForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfFeatures);
153 virtual double getGoodMovingEdgesRatioThreshold()
const;
155 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 156 virtual std::vector<vpImagePoint> getKltImagePoints()
const;
157 virtual std::map<int, vpImagePoint> getKltImagePointsWithId()
const;
159 virtual unsigned int getKltMaskBorder()
const;
160 virtual int getKltNbPoints()
const;
164 virtual void getKltOpencv(std::map<std::string, vpKltOpencv> &mapOfKlts)
const;
166 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408) 167 virtual std::vector<cv::Point2f> getKltPoints()
const;
170 virtual double getKltThresholdAcceptation()
const;
173 virtual void getLcircle(std::list<vpMbtDistanceCircle *> &circlesList,
unsigned int level = 0)
const;
174 virtual void getLcircle(
const std::string &cameraName, std::list<vpMbtDistanceCircle *> &circlesList,
175 unsigned int level = 0)
const;
176 virtual void getLcylinder(std::list<vpMbtDistanceCylinder *> &cylindersList,
unsigned int level = 0)
const;
177 virtual void getLcylinder(
const std::string &cameraName, std::list<vpMbtDistanceCylinder *> &cylindersList,
178 unsigned int level = 0)
const;
179 virtual void getLline(std::list<vpMbtDistanceLine *> &linesList,
unsigned int level = 0)
const;
180 virtual void getLline(
const std::string &cameraName, std::list<vpMbtDistanceLine *> &linesList,
181 unsigned int level = 0)
const;
183 virtual std::vector<std::vector<double> >
getModelForDisplay(
unsigned int width,
unsigned int height,
186 bool displayFullModel=
false);
187 virtual void getModelForDisplay(std::map<std::string, std::vector<std::vector<double> > > &mapOfModels,
188 const std::map<std::string, unsigned int> &mapOfwidths,
189 const std::map<std::string, unsigned int> &mapOfheights,
190 const std::map<std::string, vpHomogeneousMatrix> &mapOfcMos,
191 const std::map<std::string, vpCameraParameters> &mapOfCams,
192 bool displayFullModel=
false);
194 virtual vpMe getMovingEdge()
const;
195 virtual void getMovingEdge(
vpMe &me1,
vpMe &me2)
const;
196 virtual void getMovingEdge(std::map<std::string, vpMe> &mapOfMovingEdges)
const;
198 virtual unsigned int getNbPoints(
unsigned int level = 0)
const;
199 virtual void getNbPoints(std::map<std::string, unsigned int> &mapOfNbPoints,
unsigned int level = 0)
const;
202 virtual void getNbPolygon(std::map<std::string, unsigned int> &mapOfNbPolygons)
const;
207 virtual std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
208 getPolygonFaces(
bool orderPolygons =
true,
bool useVisibility =
true,
bool clipPolygon =
false);
209 virtual void getPolygonFaces(std::map<std::string, std::vector<vpPolygon> > &mapOfPolygons,
210 std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
211 bool orderPolygons =
true,
bool useVisibility =
true,
212 bool clipPolygon =
false);
217 virtual void getPose(std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
const;
219 virtual std::string getReferenceCameraName()
const;
223 virtual int getTrackerType()
const;
227 #ifdef VISP_HAVE_MODULE_GUI 230 const std::string &initFile1,
const std::string &initFile2,
bool displayHelp =
false,
233 const std::string &initFile1,
const std::string &initFile2,
bool displayHelp =
false,
237 const std::map<std::string, std::string> &mapOfInitFiles,
bool displayHelp =
false,
238 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
240 const std::map<std::string, std::string> &mapOfInitFiles,
bool displayHelp =
false,
241 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
246 const std::string &initFile1,
const std::string &initFile2);
248 const std::string &initFile1,
const std::string &initFile2);
251 const std::map<std::string, std::string> &mapOfInitPoints);
253 const std::map<std::string, std::string> &mapOfInitPoints);
258 const std::string &initFile1,
const std::string &initFile2);
260 const std::string &initFile1,
const std::string &initFile2);
263 const std::map<std::string, std::string> &mapOfInitPoses);
265 const std::map<std::string, std::string> &mapOfInitPoses);
273 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
275 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
278 virtual void loadConfigFile(
const std::string &configFile1,
const std::string &configFile2);
279 virtual void loadConfigFile(
const std::map<std::string, std::string> &mapOfConfigFiles);
282 virtual void loadModel(
const std::string &modelFile1,
const std::string &modelFile2,
bool verbose =
false,
284 virtual void loadModel(
const std::map<std::string, std::string> &mapOfModelFiles,
bool verbose =
false,
285 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
290 virtual void reInitModel(
const vpImage<vpRGBa> &I_color,
const std::string &cad_name,
295 const std::string &cad_name1,
const std::string &cad_name2,
const vpHomogeneousMatrix &c1Mo,
299 const std::string &cad_name1,
const std::string &cad_name2,
const vpHomogeneousMatrix &c1Mo,
304 const std::map<std::string, std::string> &mapOfModelFiles,
305 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
306 bool verbose =
false,
307 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
308 virtual void reInitModel(
const std::map<std::string,
const vpImage<vpRGBa> *> &mapOfColorImages,
309 const std::map<std::string, std::string> &mapOfModelFiles,
310 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
311 bool verbose =
false,
312 const std::map<std::string, vpHomogeneousMatrix> &mapOfT=std::map<std::string, vpHomogeneousMatrix>());
318 virtual void setAngleAppear(
const std::map<std::string, double> &mapOfAngles);
322 virtual void setAngleDisappear(
const std::map<std::string, double> &mapOfAngles);
326 virtual void setCameraParameters(
const std::map<std::string, vpCameraParameters> &mapOfCameraParameters);
328 virtual void setCameraTransformationMatrix(
const std::string &cameraName,
331 setCameraTransformationMatrix(
const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix);
333 virtual void setClipping(
const unsigned int &flags);
334 virtual void setClipping(
const unsigned int &flags1,
const unsigned int &flags2);
335 virtual void setClipping(
const std::map<std::string, unsigned int> &mapOfClippingFlags);
337 virtual void setDepthDenseFilteringMaxDistance(
double maxDistance);
338 virtual void setDepthDenseFilteringMethod(
int method);
339 virtual void setDepthDenseFilteringMinDistance(
double minDistance);
340 virtual void setDepthDenseFilteringOccupancyRatio(
double occupancyRatio);
341 virtual void setDepthDenseSamplingStep(
unsigned int stepX,
unsigned int stepY);
345 virtual void setDepthNormalPclPlaneEstimationMethod(
int method);
346 virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(
int maxIter);
347 virtual void setDepthNormalPclPlaneEstimationRansacThreshold(
double threshold);
348 virtual void setDepthNormalSamplingStep(
unsigned int stepX,
unsigned int stepY);
356 virtual void setFeatureFactors(
const std::map<vpTrackerType, double> &mapOfFeatureFactors);
358 virtual void setGoodMovingEdgesRatioThreshold(
double threshold);
360 #ifdef VISP_HAVE_OGRE 365 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 366 virtual void setKltMaskBorder(
const unsigned int &e);
367 virtual void setKltMaskBorder(
const unsigned int &e1,
const unsigned int &e2);
368 virtual void setKltMaskBorder(
const std::map<std::string, unsigned int> &mapOfErosions);
372 virtual void setKltOpencv(
const std::map<std::string, vpKltOpencv> &mapOfKlts);
374 virtual void setKltThresholdAcceptation(
double th);
378 virtual void setLod(
bool useLod,
const std::string &name =
"");
385 virtual void setMovingEdge(
const vpMe &me);
386 virtual void setMovingEdge(
const vpMe &me1,
const vpMe &me2);
387 virtual void setMovingEdge(
const std::map<std::string, vpMe> &mapOfMe);
407 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
409 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses);
417 virtual void setReferenceCameraName(
const std::string &referenceCameraName);
421 virtual void setTrackerType(
int type);
422 virtual void setTrackerType(
const std::map<std::string, int> &mapOfTrackerTypes);
424 virtual void setUseDepthDenseTracking(
const std::string &name,
const bool &useDepthDenseTracking);
425 virtual void setUseDepthNormalTracking(
const std::string &name,
const bool &useDepthNormalTracking);
426 virtual void setUseEdgeTracking(
const std::string &name,
const bool &useEdgeTracking);
427 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 428 virtual void setUseKltTracking(
const std::string &name,
const bool &useKltTracking);
444 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
446 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
450 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
451 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
452 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
454 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
455 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
456 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
459 virtual void computeProjectionError();
467 std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist);
472 int idFace = 0,
const std::string &name =
"");
475 const std::string &name =
"");
483 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds);
486 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
487 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
488 std::map<std::string, unsigned int> &mapOfPointCloudHeights);
492 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 513 explicit TrackerWrapper(
int trackerType);
515 virtual ~TrackerWrapper();
521 virtual inline int getTrackerType()
const {
return m_trackerType; }
524 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
526 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false);
530 virtual std::vector<std::vector<double> >
getModelForDisplay(
unsigned int width,
unsigned int height,
533 bool displayFullModel=
false);
550 virtual void setClipping(
const unsigned int &flags);
574 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6)) 580 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
594 int idFace = 0,
const std::string &name =
"");
597 const std::string &name =
"");
606 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
608 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud);
610 virtual void postTracking(
const vpImage<unsigned char> *
const ptr_I = NULL,
const unsigned int pointcloud_width = 0,
611 const unsigned int pointcloud_height = 0);
613 const std::vector<vpColVector> *
const point_cloud = NULL,
614 const unsigned int pointcloud_width = 0,
const unsigned int pointcloud_height = 0);
623 #if !((__GNUC__ == 4) && (__GNUC_MINOR__ == 6)) virtual unsigned int getClipping() const
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void loadConfigFile(const std::string &configFile)
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(bool orderPolygons=true, bool useVisibility=true, bool clipPolygon=false)
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 computeVVSInit()=0
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
vpColVector m_w
Robust weights.
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setAngleDisappear(const double &a)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void setTrackerType(int type)
virtual void track(const vpImage< unsigned char > &I)
virtual int getTrackerType() const
virtual void resetTracker()
virtual void track(const vpImage< unsigned char > &)
virtual void loadConfigFile(const std::string &configFile)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
virtual vpMbtPolygon * getPolygon(unsigned int index)
Class to define colors available for display functionnalities.
virtual void setClipping(const unsigned int &flags)
virtual void track(const vpImage< unsigned char > &)
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")=0
virtual void setOgreShowConfigDialog(bool showConfigDialog)
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 void computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages)
virtual void setLod(bool useLod, const std::string &name="")
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)=0
virtual void setProjectionErrorDisplayArrowLength(unsigned int length)
Class that defines what is a point.
virtual void init(const vpImage< unsigned char > &I)=0
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
vpMatrix m_L
Interaction matrix.
virtual vpHomogeneousMatrix getPose() const
virtual void initFaceFromLines(vpMbtPolygon &polygon)
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
vpColVector m_weightedError
Weighted error.
virtual void setCameraParameters(const vpCameraParameters &cam)
Implementation of a polygon of the model used by the model-based tracker.
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
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 std::vector< std::vector< double > > getFeaturesForDisplay()
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
virtual void computeVVSWeights()
virtual void testTracking()
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
virtual void setProjectionErrorDisplay(bool display)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)=0
virtual void setNearClippingDistance(const double &dist)
virtual vpColVector getError() const
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void setProjectionErrorDisplayArrowThickness(unsigned int thickness)
virtual void setScanLineVisibilityTest(const bool &v)
virtual vpColVector getRobustWeights() const
virtual void setOgreVisibilityTest(const bool &v)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")
virtual unsigned int getNbPolygon() const
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 initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")=0
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 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 setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void setFarClippingDistance(const double &dist)
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
virtual void setDisplayFeatures(bool displayF)
virtual void getCameraParameters(vpCameraParameters &cam) const
double m_thresholdOutlier
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setNearClippingDistance(const double &dist)