39 #ifndef _vpMbKltTracker_h_
40 #define _vpMbKltTracker_h_
42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
46 #include <visp3/core/vpExponentialMap.h>
47 #include <visp3/core/vpMeterPixelConversion.h>
48 #include <visp3/core/vpPixelMeterConversion.h>
49 #include <visp3/core/vpSubColVector.h>
50 #include <visp3/core/vpSubMatrix.h>
51 #include <visp3/klt/vpKltOpencv.h>
52 #include <visp3/mbt/vpMbTracker.h>
53 #include <visp3/mbt/vpMbtDistanceCircle.h>
54 #include <visp3/mbt/vpMbtDistanceKltCylinder.h>
55 #include <visp3/mbt/vpMbtDistanceKltPoints.h>
56 #include <visp3/vision/vpHomography.h>
218 class VISP_EXPORT vpMbKltTracker :
public virtual vpMbTracker
227 bool firstInitialisation;
229 unsigned int maskBorder;
232 double threshold_outlier;
242 std::list<vpMbtDistanceKltPoints *> kltPolygons;
244 std::list<vpMbtDistanceKltCylinder *> kltCylinders;
246 std::list<vpMbtDistanceCircle *> circles_disp;
248 unsigned int m_nbInfos;
250 unsigned int m_nbFaceUsed;
262 std::vector<std::vector<double> > m_featuresToBeDisplayedKlt;
266 virtual ~vpMbKltTracker();
271 void addCircle(
const vpPoint &P1,
const vpPoint &P2,
const vpPoint &P3,
double r,
const std::string &name =
"");
273 const vpColor &col,
unsigned int thickness = 1,
bool displayFullModel =
false) VP_OVERRIDE;
275 const
vpColor &col,
unsigned int thickness = 1,
bool displayFullModel = false) VP_OVERRIDE;
280 virtual std::list<vpMbtDistanceKltCylinder *> &getFeaturesKltCylinder() {
return kltCylinders; }
282 virtual std::list<vpMbtDistanceKltPoints *> &getFeaturesKlt() {
return kltPolygons; }
289 inline std::vector<cv::Point2f> getKltPoints()
const {
return tracker.
getFeatures(); }
291 std::vector<vpImagePoint> getKltImagePoints()
const;
293 std::map<int, vpImagePoint> getKltImagePointsWithId()
const;
300 inline vpKltOpencv getKltOpencv()
const {
return tracker; }
307 inline unsigned int getKltMaskBorder()
const {
return maskBorder; }
314 inline int getKltNbPoints()
const {
return tracker.
getNbFeatures(); }
322 inline double getKltThresholdAcceptation()
const {
return threshold_outlier; }
328 virtual std::vector<std::vector<double> >
getModelForDisplay(
unsigned int width,
unsigned int height,
331 bool displayFullModel =
false) VP_OVERRIDE;
333 virtual
void loadConfigFile(const std::
string &configFile,
bool verbose = true) VP_OVERRIDE;
337 void resetTracker() VP_OVERRIDE;
346 inline
void setKltMaskBorder(const
unsigned int &e)
350 faces.getMbScanLineRenderer().setMaskBorder(maskBorder);
360 inline void setKltThresholdAcceptation(
double th) { threshold_outlier = th; }
373 #ifdef VISP_HAVE_OGRE
374 faces.getOgreContext()->setWindowName(
"MBT Klt");
387 for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = kltPolygons.begin(); it != kltPolygons.end(); ++it)
388 (*it)->useScanLine = v;
403 std::cerr <<
"This option is not yet implemented in vpMbKltTracker, "
404 "projection error computation set to false."
408 void setUseKltTracking(
const std::string &name,
const bool &useKltTracking);
411 virtual
void track(const
vpImage<
unsigned char> &I) VP_OVERRIDE;
412 virtual
void track(const
vpImage<
vpRGBa> &I_color) VP_OVERRIDE;
425 inline
unsigned int getMaskBorder()
const {
return maskBorder; }
433 inline int getNbKltPoints()
const {
return tracker.
getNbFeatures(); }
442 inline double getThresholdAcceptation()
const {
return threshold_outlier; }
449 inline void setMaskBorder(
const unsigned int &e)
453 faces.getMbScanLineRenderer().setMaskBorder(maskBorder);
462 inline void setThresholdAcceptation(
double th) { threshold_outlier = th; }
471 virtual
void computeVVSInteractionMatrixAndResidu() VP_OVERRIDE;
473 virtual std::vector<std::vector<
double> > getFeaturesForDisplayKlt();
475 virtual
void init(const
vpImage<
unsigned char> &I) VP_OVERRIDE;
476 virtual
void initFaceFromCorners(
vpMbtPolygon &polygon) VP_OVERRIDE;
477 virtual
void initFaceFromLines(
vpMbtPolygon &polygon) VP_OVERRIDE;
478 virtual
void initCircle(const
vpPoint &, const
vpPoint &, const
vpPoint &,
double,
int, const std::
string &name = "") VP_OVERRIDE;
479 virtual
void initCylinder(const
vpPoint &, const
vpPoint &,
double,
int, const std::
string &name = "") VP_OVERRIDE;
481 void preTracking(const
vpImage<
unsigned char> &I);
483 virtual
void reinit(const
vpImage<
unsigned char> &I);
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.
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
int getNbFeatures() const
Get the number of current features.
std::vector< cv::Point2f > getFeatures() const
Get the list of current features.
Implementation of a matrix and operations on matrices.
Main methods for a 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)=0
virtual vpColVector getError() const =0
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setOgreVisibilityTest(const bool &v)
virtual vpColVector getRobustWeights() const =0
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)=0
virtual void setProjectionErrorComputation(const bool &flag)
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 computeVVSInit()=0
virtual void testTracking()=0
Manage a circle used in the model-based tracker.
Implementation of a polygon of the model used by the model-based tracker.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Contains an M-estimator and various influence function.