diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h index b42f849550..0dd98709d4 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h @@ -1,5 +1,4 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. * Copyright (C) 2005 - 2023 by Inria. All rights reserved. * @@ -30,8 +29,7 @@ * * Description: * Model-based tracker using depth dense features. - * -*****************************************************************************/ + */ #ifndef _vpMbDepthDenseTracker_h_ #define _vpMbDepthDenseTracker_h_ diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h index 72678f823e..c48d2fd5f4 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h @@ -1,5 +1,4 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. * Copyright (C) 2005 - 2023 by Inria. All rights reserved. * @@ -30,8 +29,7 @@ * * Description: * Model-based tracker using depth normal features. - * -*****************************************************************************/ + */ #ifndef _vpMbDepthNormalTracker_h_ #define _vpMbDepthNormalTracker_h_ diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h index 73152356c9..6d6a6be8fd 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h @@ -1,5 +1,4 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. * Copyright (C) 2005 - 2023 by Inria. All rights reserved. * @@ -30,13 +29,12 @@ * * Description: * Hybrid tracker based on edges (vpMbt) and points of interests (KLT) - * -*****************************************************************************/ + */ /*! - \file vpMbEdgeKltTracker.h - \brief Hybrid tracker based on edges (vpMbt) and points of interests (KLT) -*/ + * \file vpMbEdgeKltTracker.h + * \brief Hybrid tracker based on edges (vpMbt) and points of interests (KLT) + */ #ifndef _vpMbEdgeKltTracker_h_ #define _vpMbEdgeKltTracker_h_ @@ -55,156 +53,156 @@ #include /*! - \class vpMbEdgeKltTracker - \ingroup group_mbt_trackers - \warning This class is deprecated for user usage. You should rather use the high level - vpMbGenericTracker class. - \warning This class is only available if OpenCV is installed, and used. - - \brief Hybrid tracker based on moving-edges and keypoints tracked using KLT - tracker. - - The \ref tutorial-tracking-mb-deprecated is a good starting point to use this class. - - The tracker requires the knowledge of the 3D model that could be provided in - a vrml or in a cao file. The cao format is described in loadCAOModel(). It may - also use an xml file used to tune the behavior of the tracker and an init file - used to compute the pose at the very first image. - - The following code shows the simplest way to use the tracker. The \ref - tutorial-tracking-mb-deprecated is also a good starting point to use this class. - -\code -#include -#include -#include -#include -#include -#include - -int main() -{ -#if defined VISP_HAVE_OPENCV - vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. - vpImage I; - vpHomogeneousMatrix cMo; // Pose computed using the tracker. - vpCameraParameters cam; - - // Acquire an image - vpImageIo::read(I, "cube.pgm"); - -#if defined(VISP_HAVE_X11) - vpDisplayX display; - display.init(I,100,100,"Mb Hybrid Tracker"); -#endif - - tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker - // Load the 3d model in cao format. No 3rd party library is required - tracker.loadModel("cube.cao"); - // Get the camera parameters used by the tracker (from the configuration file). - tracker.getCameraParameters(cam); - // Initialise manually the pose by clicking on the image points associated to the 3d points contained in the - // cube.init file. - tracker.initClick(I, "cube.init"); - - while(true){ - // Acquire a new image - vpDisplay::display(I); - tracker.track(I); // Track the object on this image - tracker.getPose(cMo); // Get the pose - - tracker.display(I, cMo, cam, vpColor::darkRed, 1); // Display the model at the computed pose. - vpDisplay::flush(I); - } - - return 0; -#endif -} -\endcode - - The tracker can also be used without display, in that case the initial pose - must be known (object always at the same initial pose for example) or -computed using another method: - -\code -#include -#include -#include -#include -#include - -int main() -{ -#if defined VISP_HAVE_OPENCV - vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. - vpImage I; - vpHomogeneousMatrix cMo; // Pose used in entry (has to be defined), then computed using the tracker. - - //acquire an image - vpImageIo::read(I, "cube.pgm"); // Example of acquisition - - tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker - // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. - tracker.loadModel("cube.cao"); - tracker.initFromPose(I, cMo); // initialise the tracker with the given pose. - - while(true){ - // acquire a new image - tracker.track(I); // track the object on this image - tracker.getPose(cMo); // get the pose - } - - return 0; -#endif -} -\endcode - - Finally it can be used not to track an object but just to display a model at -a given pose: - -\code -#include -#include -#include -#include -#include -#include - -int main() -{ -#if defined VISP_HAVE_OPENCV - vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. - vpImage I; - vpHomogeneousMatrix cMo; // Pose used to display the model. - vpCameraParameters cam; - - // Acquire an image - vpImageIo::read(I, "cube.pgm"); - -#if defined(VISP_HAVE_X11) - vpDisplayX display; - display.init(I,100,100,"Mb Hybrid Tracker"); -#endif - - tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker - tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). - // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. - tracker.loadModel("cube.cao"); - - while(true){ - // acquire a new image - // Get the pose using any method - vpDisplay::display(I); - tracker.display(I, cMo, cam, vpColor::darkRed, 1, true); // Display the model at the computed pose. - vpDisplay::flush(I); - } - -#endif - - return 0; -} -\endcode -*/ + * \class vpMbEdgeKltTracker + * \ingroup group_mbt_trackers + * \warning This class is deprecated for user usage. You should rather use the high level + * vpMbGenericTracker class. + * \warning This class is only available if OpenCV is installed, and used. + * + * \brief Hybrid tracker based on moving-edges and keypoints tracked using KLT + * tracker. + * + * The \ref tutorial-tracking-mb-deprecated is a good starting point to use this class. + * + * The tracker requires the knowledge of the 3D model that could be provided in + * a vrml or in a cao file. The cao format is described in loadCAOModel(). It may + * also use an xml file used to tune the behavior of the tracker and an init file + * used to compute the pose at the very first image. + * + * The following code shows the simplest way to use the tracker. The \ref + * tutorial-tracking-mb-deprecated is also a good starting point to use this class. + * + * \code + * #include + * #include + * #include + * #include + * #include + * #include + * + * int main() + * { + * #if defined VISP_HAVE_OPENCV + * vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. + * vpImage I; + * vpHomogeneousMatrix cMo; // Pose computed using the tracker. + * vpCameraParameters cam; + * + * // Acquire an image + * vpImageIo::read(I, "cube.pgm"); + * + * #if defined(VISP_HAVE_X11) + * vpDisplayX display; + * display.init(I,100,100,"Mb Hybrid Tracker"); + * #endif + * + * tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker + * // Load the 3d model in cao format. No 3rd party library is required + * tracker.loadModel("cube.cao"); + * // Get the camera parameters used by the tracker (from the configuration file). + * tracker.getCameraParameters(cam); + * // Initialise manually the pose by clicking on the image points associated to the 3d points contained in the + * // cube.init file. + * tracker.initClick(I, "cube.init"); + * + * while(true){ + * // Acquire a new image + * vpDisplay::display(I); + * tracker.track(I); // Track the object on this image + * tracker.getPose(cMo); // Get the pose + * + * tracker.display(I, cMo, cam, vpColor::darkRed, 1); // Display the model at the computed pose. + * vpDisplay::flush(I); + * } + * + * return 0; + * #endif + * } + * \endcode + * + * The tracker can also be used without display, in that case the initial pose + * must be known (object always at the same initial pose for example) or + * computed using another method: + * + * \code + * #include + * #include + * #include + * #include + * #include + * + * int main() + * { + * #if defined VISP_HAVE_OPENCV + * vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. + * vpImage I; + * vpHomogeneousMatrix cMo; // Pose used in entry (has to be defined), then computed using the tracker. + * + * //acquire an image + * vpImageIo::read(I, "cube.pgm"); // Example of acquisition + * + * tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker + * // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. + * tracker.loadModel("cube.cao"); + * tracker.initFromPose(I, cMo); // initialise the tracker with the given pose. + * + * while(true){ + * // acquire a new image + * tracker.track(I); // track the object on this image + * tracker.getPose(cMo); // get the pose + * } + * + * return 0; + * #endif + * } + * \endcode + * + * Finally it can be used not to track an object but just to display a model at + * a given pose: + * + * \code + * #include + * #include + * #include + * #include + * #include + * #include + * + * int main() + * { + * #if defined VISP_HAVE_OPENCV + * vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. + * vpImage I; + * vpHomogeneousMatrix cMo; // Pose used to display the model. + * vpCameraParameters cam; + * + * // Acquire an image + * vpImageIo::read(I, "cube.pgm"); + * + * #if defined(VISP_HAVE_X11) + * vpDisplayX display; + * display.init(I,100,100,"Mb Hybrid Tracker"); + * #endif + * + * tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker + * tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). + * // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. + * tracker.loadModel("cube.cao"); + * + * while(true){ + * // acquire a new image + * // Get the pose using any method + * vpDisplay::display(I); + * tracker.display(I, cMo, cam, vpColor::darkRed, 1, true); // Display the model at the computed pose. + * vpDisplay::flush(I); + * } + * + * #endif + * + * return 0; + * } + * \endcode + */ class VISP_EXPORT vpMbEdgeKltTracker : #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO) public vpMbKltTracker, @@ -246,11 +244,11 @@ class VISP_EXPORT vpMbEdgeKltTracker : virtual inline vpColVector getRobustWeights() const override { return m_w_hybrid; } /*! - Get the near distance for clipping. - - \return Near clipping value. + * Get the near distance for clipping. + * + * \return Near clipping value. */ - virtual inline double getNearClippingDistance() const { return vpMbKltTracker::getNearClippingDistance(); } + virtual inline double getNearClippingDistance() const override { return vpMbKltTracker::getNearClippingDistance(); } virtual void loadConfigFile(const std::string &configFile, bool verbose = true) override; @@ -261,35 +259,35 @@ class VISP_EXPORT vpMbEdgeKltTracker : virtual void setCameraParameters(const vpCameraParameters &cam) override; /*! - Specify which clipping to use. - - \sa vpMbtPolygonClipping - - \param flags : New clipping flags. + * Specify which clipping to use. + * + * \sa vpMbtPolygonClipping + * + * \param flags : New clipping flags. */ virtual void setClipping(const unsigned int &flags) override { vpMbEdgeTracker::setClipping(flags); } /*! - Set the far distance for clipping. - - \param dist : Far clipping value. + * Set the far distance for clipping. + * + * \param dist : Far clipping value. */ virtual void setFarClippingDistance(const double &dist) override { vpMbEdgeTracker::setFarClippingDistance(dist); } /*! - Set the near distance for clipping. - - \param dist : Near clipping value. + * Set the near distance for clipping. + * + * \param dist : Near clipping value. */ virtual void setNearClippingDistance(const double &dist) override { vpMbEdgeTracker::setNearClippingDistance(dist); } /*! - Use Ogre3D for visibility tests - - \warning This function has to be called before the initialization of the - tracker. - - \param v : True to use it, False otherwise + * Use Ogre3D for visibility tests + * + * \warning This function has to be called before the initialization of the + * tracker. + * + * \param v : True to use it, False otherwise */ virtual void setOgreVisibilityTest(const bool &v) override { @@ -300,10 +298,10 @@ class VISP_EXPORT vpMbEdgeKltTracker : } /*! - Use Scanline algorithm for visibility tests - - \param v : True to use it, False otherwise - */ + * Use Scanline algorithm for visibility tests + * + * \param v : True to use it, False otherwise + */ virtual void setScanLineVisibilityTest(const bool &v) override { vpMbEdgeTracker::setScanLineVisibilityTest(v); @@ -312,6 +310,7 @@ class VISP_EXPORT vpMbEdgeKltTracker : virtual void setPose(const vpImage &I, const vpHomogeneousMatrix &cdMo) override; virtual void setPose(const vpImage &I_color, const vpHomogeneousMatrix &cdMo) override; + /*! * Set if the projection error criteria has to be computed. * diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h index fd8e63dc8d..ca3b07483b 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h @@ -1,5 +1,4 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. * Copyright (C) 2005 - 2023 by Inria. All rights reserved. * @@ -30,12 +29,12 @@ * * Description: * Generic model-based tracker. - * -*****************************************************************************/ + */ + /*! - \file vpMbGenericTracker.h - \brief Generic model-based tracker -*/ + * \file vpMbGenericTracker.h + *\brief Generic model-based tracker + */ #ifndef _vpMbGenericTracker_h_ #define _vpMbGenericTracker_h_ @@ -51,151 +50,150 @@ #endif /*! - \class vpMbGenericTracker - \ingroup group_mbt_trackers - \brief Real-time 6D object pose tracking using its CAD model. - - The tracker requires the knowledge of the 3D model that could be provided in - a vrml or in a cao file. The cao format is described in loadCAOModel(). It may - also use an xml file used to tune the behavior of the tracker and an init file - used to compute the pose at the very first image. - - This class allows tracking an object or a scene given its 3D model. More information in \cite Trinh18a. - A lot of videos can be found on YouTube VispTeam channel. - - \htmlonly - - - - - \endhtmlonly - - The \ref tutorial-tracking-mb-generic is a good starting point to use this - class. If you want to track an object with a stereo camera refer to - \ref tutorial-tracking-mb-generic-stereo. If you want rather use a RGB-D camera and exploit - the depth information, you may see \ref tutorial-tracking-mb-generic-rgbd. - There is also \ref tutorial-detection-object that shows how to initialize the tracker from - an initial pose provided by a detection algorithm. - - JSON serialization - - Since ViSP 3.6.0, if ViSP is build with \ref soft_tool_json 3rd-party we introduce JSON serialization capabilities for vpMbGenericTracker. - The following sample code shows how to save a model-based tracker settings in a file named `mbt.json` - and reload the values from this JSON file. - \code - #include - - int main() - { - #if defined(VISP_HAVE_NLOHMANN_JSON) - std::string filename = "mbt-generic.json"; - { - vpMbGenericTracker mbt; - mbt.saveConfigFile(filename); - } - { - vpMbGenericTracker mbt; - bool verbose = false; - std::cout << "Read model-based tracker settings from " << filename << std::endl; - mbt.loadConfigFile(filename, verbose); - } - #endif - } - \endcode - If you build and execute the sample code, it will produce the following output: - \code{.unparsed} - Read model-based tracker settings from mbt-generic.json - \endcode - - The content of the `mbt.json` file is the following: - \code{.unparsed} - $ cat mbt-generic.json - { - "referenceCameraName": "Camera", - "trackers": { - "Camera": { - "angleAppear": 89.0, - "angleDisappear": 89.0, - "camTref": { - "cols": 4, - "data": [ - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0 - ], - "rows": 4, - "type": "vpHomogeneousMatrix" - }, - "camera": { - "model": "perspectiveWithoutDistortion", - "px": 600.0, - "py": 600.0, - "u0": 192.0, - "v0": 144.0 - }, - "clipping": { - "far": 100.0, - "flags": [ - "none" - ], - "near": 0.001 - }, - "display": { - "features": false, - "projectionError": false - }, - "edge": { - "maskSign": 0, - "maskSize": 5, - "minSampleStep": 4.0, - "mu": [ - 0.5, - 0.5 - ], - "nMask": 180, - "ntotalSample": 0, - "pointsToTrack": 500, - "range": 4, - "sampleStep": 10.0, - "strip": 2, - "threshold": 1500.0 - }, - "lod": { - "minLineLengthThresholdGeneral": 50.0, - "minPolygonAreaThresholdGeneral": 2500.0, - "useLod": false - }, - "type": [ - "edge" - ], - "visibilityTest": { - "ogre": false, - "scanline": false - } - } - }, - "version": "1.0" - } - \endcode - -*/ + * \class vpMbGenericTracker + * \ingroup group_mbt_trackers + * \brief Real-time 6D object pose tracking using its CAD model. + * + * The tracker requires the knowledge of the 3D model that could be provided in + * a vrml or in a cao file. The cao format is described in loadCAOModel(). It may + * also use an xml file used to tune the behavior of the tracker and an init file + * used to compute the pose at the very first image. + * + * This class allows tracking an object or a scene given its 3D model. More information in \cite Trinh18a. + * A lot of videos can be found on YouTube VispTeam channel. + * + * \htmlonly + * + * + * + * + * \endhtmlonly + * + * The \ref tutorial-tracking-mb-generic is a good starting point to use this + * class. If you want to track an object with a stereo camera refer to + * \ref tutorial-tracking-mb-generic-stereo. If you want rather use a RGB-D camera and exploit + * the depth information, you may see \ref tutorial-tracking-mb-generic-rgbd. + * There is also \ref tutorial-detection-object that shows how to initialize the tracker from + * an initial pose provided by a detection algorithm. + * + * JSON serialization + * + * Since ViSP 3.6.0, if ViSP is build with \ref soft_tool_json 3rd-party we introduce JSON serialization capabilities for vpMbGenericTracker. + * The following sample code shows how to save a model-based tracker settings in a file named `mbt.json` + * and reload the values from this JSON file. + * \code + * #include + * + * int main() + * { + * #if defined(VISP_HAVE_NLOHMANN_JSON) + * std::string filename = "mbt-generic.json"; + * { + * vpMbGenericTracker mbt; + * mbt.saveConfigFile(filename); + * } + * { + * vpMbGenericTracker mbt; + * bool verbose = false; + * std::cout << "Read model-based tracker settings from " << filename << std::endl; + * mbt.loadConfigFile(filename, verbose); + * } + * #endif + * } + * \endcode + * If you build and execute the sample code, it will produce the following output: + * \code{.unparsed} + * Read model-based tracker settings from mbt-generic.json + * \endcode + * + * The content of the `mbt.json` file is the following: + * \code{.unparsed} + * $ cat mbt-generic.json + * { + * "referenceCameraName": "Camera", + * "trackers": { + * "Camera": { + * "angleAppear": 89.0, + * "angleDisappear": 89.0, + * "camTref": { + * "cols": 4, + * "data": [ + * 1.0, + * 0.0, + * 0.0, + * 0.0, + * 0.0, + * 1.0, + * 0.0, + * 0.0, + * 0.0, + * 0.0, + * 1.0, + * 0.0, + * 0.0, + * 0.0, + * 0.0, + * 1.0 + * ], + * "rows": 4, + * "type": "vpHomogeneousMatrix" + * }, + * "camera": { + * "model": "perspectiveWithoutDistortion", + * "px": 600.0, + * "py": 600.0, + * "u0": 192.0, + * "v0": 144.0 + * }, + * "clipping": { + * "far": 100.0, + * "flags": [ + * "none" + * ], + * "near": 0.001 + * }, + * "display": { + * "features": false, + * "projectionError": false + * }, + * "edge": { + * "maskSign": 0, + * "maskSize": 5, + * "minSampleStep": 4.0, + * "mu": [ + * 0.5, + * 0.5 + * ], + * "nMask": 180, + * "ntotalSample": 0, + * "pointsToTrack": 500, + * "range": 4, + * "sampleStep": 10.0, + * "strip": 2, + * "threshold": 1500.0 + * }, + * "lod": { + * "minLineLengthThresholdGeneral": 50.0, + * "minPolygonAreaThresholdGeneral": 2500.0, + * "useLod": false + * }, + * "type": [ + * "edge" + * ], + * "visibilityTest": { + * "ogre": false, + * "scanline": false + * } + * } + * }, + * "version": "1.0" + * } + * \endcode + */ class VISP_EXPORT vpMbGenericTracker : public vpMbTracker { public: @@ -319,16 +317,19 @@ class VISP_EXPORT vpMbGenericTracker : public vpMbTracker * Return the number of depth dense features taken into account in the virtual visual-servoing scheme. */ virtual inline unsigned int getNbFeaturesDepthDense() const { return m_nb_feat_depthDense; } + /*! * Return the number of depth normal features features taken into account in the virtual visual-servoing scheme. */ virtual inline unsigned int getNbFeaturesDepthNormal() const { return m_nb_feat_depthNormal; } + /*! * Return the number of moving-edges features taken into account in the virtual visual-servoing scheme. * * This function is similar to getNbPoints(). */ virtual inline unsigned int getNbFeaturesEdge() const { return m_nb_feat_edge; } + /*! * Return the number of klt keypoints features taken into account in the virtual visual-servoing scheme. */ @@ -849,7 +850,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(vpMbGenericTracker::vpTrackerType, { * @brief Serialize a tracker wrapper's settings into a JSON representation. * \sa from_json for more details on what is serialized * @param j The modified json object. -* @param t The tracker to serialize. +* @param t The tracker to serialize. */ inline void to_json(nlohmann::json &j, const vpMbGenericTracker::TrackerWrapper &t) { @@ -1047,5 +1048,4 @@ inline void from_json(const nlohmann::json &j, vpMbGenericTracker::TrackerWrappe #endif - #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h index 87b99217b2..448f7b4bc3 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h @@ -1,5 +1,4 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. * Copyright (C) 2005 - 2023 by Inria. All rights reserved. * @@ -30,12 +29,12 @@ * * Description: * Model based tracker using only KLT - * -*****************************************************************************/ + */ + /*! - \file vpMbKltTracker.h - \brief Model based tracker using only KLT -*/ + * \file vpMbKltTracker.h + * \brief Model based tracker using only KLT + */ #ifndef _vpMbKltTracker_h_ #define _vpMbKltTracker_h_ @@ -57,152 +56,152 @@ #include /*! - \class vpMbKltTracker - \ingroup group_mbt_trackers - \warning This class is deprecated for user usage. You should rather use the high level - vpMbGenericTracker class. - \warning This class is only available if OpenCV is installed, and used. - - \brief Model based tracker using only KLT. - - The \ref tutorial-tracking-mb-deprecated is a good starting point to use this class. - - The tracker requires the knowledge of the 3D model that could be provided in - a vrml or in a cao file. The cao format is described in loadCAOModel(). It may - also use an xml file used to tune the behavior of the tracker and an init file - used to compute the pose at the very first image. - - The following code shows the simplest way to use the tracker. The \ref - tutorial-tracking-mb-deprecated is also a good starting point to use this class. - -\code -#include -#include -#include -#include -#include -#include - -int main() -{ -#if defined VISP_HAVE_OPENCV - vpMbKltTracker tracker; // Create a model based tracker via KLT points. - vpImage I; - vpHomogeneousMatrix cMo; // Pose computed using the tracker. - vpCameraParameters cam; - - // Acquire an image - vpImageIo::read(I, "cube.pgm"); - -#if defined(VISP_HAVE_X11) - vpDisplayX display; - display.init(I,100,100,"Mb Klt Tracker"); -#endif - - tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker - tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). - tracker.loadModel("cube.cao"); // Load the 3d model in cao format. No 3rd party library is required - // Initialise manually the pose by clicking on the image points associated to the 3d points contained in the - // cube.init file. - tracker.initClick(I, "cube.init"); - - while(true){ - // Acquire a new image - vpDisplay::display(I); - tracker.track(I); // Track the object on this image - tracker.getPose(cMo); // Get the pose - - tracker.display(I, cMo, cam, vpColor::darkRed, 1); // Display the model at the computed pose. - vpDisplay::flush(I); - } - - return 0; -#endif -} -\endcode - - The tracker can also be used without display, in that case the initial pose - must be known (object always at the same initial pose for example) or -computed using another method: - -\code -#include -#include -#include -#include -#include - -int main() -{ -#if defined VISP_HAVE_OPENCV - vpMbKltTracker tracker; // Create a model based tracker via Klt Points. - vpImage I; - vpHomogeneousMatrix cMo; // Pose used in entry (has to be defined), then computed using the tracker. - - //acquire an image - vpImageIo::read(I, "cube.pgm"); // Example of acquisition - - tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker - // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. - tracker.loadModel("cube.cao"); - tracker.initFromPose(I, cMo); // initialize the tracker with the given pose. - - while(true){ - // acquire a new image - tracker.track(I); // track the object on this image - tracker.getPose(cMo); // get the pose - } - - return 0; -#endif -} -\endcode - - Finally it can be used not to track an object but just to display a model at -a given pose: - -\code -#include -#include -#include -#include -#include -#include - -int main() -{ -#if defined VISP_HAVE_OPENCV - vpMbKltTracker tracker; // Create a model based tracker via Klt Points. - vpImage I; - vpHomogeneousMatrix cMo; // Pose used to display the model. - vpCameraParameters cam; - - // Acquire an image - vpImageIo::read(I, "cube.pgm"); - -#if defined(VISP_HAVE_X11) - vpDisplayX display; - display.init(I,100,100,"Mb Klt Tracker"); -#endif - - tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker - tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). - // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. - tracker.loadModel("cube.cao"); - - while(true){ - // acquire a new image - // Get the pose using any method - vpDisplay::display(I); - tracker.display(I, cMo, cam, vpColor::darkRed, 1, true); // Display the model at the computed pose. - vpDisplay::flush(I); - } - - return 0; -#endif -} -\endcode -*/ + * \class vpMbKltTracker + * \ingroup group_mbt_trackers + * \warning This class is deprecated for user usage. You should rather use the high level + * vpMbGenericTracker class. + * \warning This class is only available if OpenCV is installed, and used. + * + * \brief Model based tracker using only KLT. + * + * The \ref tutorial-tracking-mb-deprecated is a good starting point to use this class. + * + * The tracker requires the knowledge of the 3D model that could be provided in + * a vrml or in a cao file. The cao format is described in loadCAOModel(). It may + * also use an xml file used to tune the behavior of the tracker and an init file + * used to compute the pose at the very first image. + * + * The following code shows the simplest way to use the tracker. The \ref + * tutorial-tracking-mb-deprecated is also a good starting point to use this class. + * + * \code + * #include + * #include + * #include + * #include + * #include + * #include + * + * int main() + * { + * #if defined VISP_HAVE_OPENCV + * vpMbKltTracker tracker; // Create a model based tracker via KLT points. + * vpImage I; + * vpHomogeneousMatrix cMo; // Pose computed using the tracker. + * vpCameraParameters cam; + * + * // Acquire an image + * vpImageIo::read(I, "cube.pgm"); + * + * #if defined(VISP_HAVE_X11) + * vpDisplayX display; + * display.init(I,100,100,"Mb Klt Tracker"); + * #endif + * + * tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker + * tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). + * tracker.loadModel("cube.cao"); // Load the 3d model in cao format. No 3rd party library is required + * // Initialise manually the pose by clicking on the image points associated to the 3d points contained in the + * // cube.init file. + * tracker.initClick(I, "cube.init"); + * + * while(true){ + * // Acquire a new image + * vpDisplay::display(I); + * tracker.track(I); // Track the object on this image + * tracker.getPose(cMo); // Get the pose + * + * tracker.display(I, cMo, cam, vpColor::darkRed, 1); // Display the model at the computed pose. + * vpDisplay::flush(I); + * } + * + * return 0; + * #endif + * } + * \endcode + * + * The tracker can also be used without display, in that case the initial pose + * must be known (object always at the same initial pose for example) or + * computed using another method: + * + * \code + * #include + * #include + * #include + * #include + * #include + * + * int main() + * { + * #if defined VISP_HAVE_OPENCV + * vpMbKltTracker tracker; // Create a model based tracker via Klt Points. + * vpImage I; + * vpHomogeneousMatrix cMo; // Pose used in entry (has to be defined), then computed using the tracker. + * + * //acquire an image + * vpImageIo::read(I, "cube.pgm"); // Example of acquisition + * + * tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker + * // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. + * tracker.loadModel("cube.cao"); + * tracker.initFromPose(I, cMo); // initialize the tracker with the given pose. + * + * while(true){ + * // acquire a new image + * tracker.track(I); // track the object on this image + * tracker.getPose(cMo); // get the pose + * } + * + * return 0; + * #endif + * } + * \endcode + * + * Finally it can be used not to track an object but just to display a model at + * a given pose: + * + * \code + * #include + * #include + * #include + * #include + * #include + * #include + * + * int main() + * { + * #if defined VISP_HAVE_OPENCV + * vpMbKltTracker tracker; // Create a model based tracker via Klt Points. + * vpImage I; + * vpHomogeneousMatrix cMo; // Pose used to display the model. + * vpCameraParameters cam; + * + * // Acquire an image + * vpImageIo::read(I, "cube.pgm"); + * + * #if defined(VISP_HAVE_X11) + * vpDisplayX display; + * display.init(I,100,100,"Mb Klt Tracker"); + * #endif + * + * tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker + * tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). + * // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. + * tracker.loadModel("cube.cao"); + * + * while(true){ + * // acquire a new image + * // Get the pose using any method + * vpDisplay::display(I); + * tracker.display(I, cMo, cam, vpColor::darkRed, 1, true); // Display the model at the computed pose. + * vpDisplay::flush(I); + * } + * + * return 0; + * #endif + * } + * \endcode + */ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker { protected: @@ -269,11 +268,11 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker /*! Return the address of the Klt feature list. */ virtual std::list &getFeaturesKlt() { return kltPolygons; } -/*! - Get the current list of KLT points. - - \return the list of KLT points through vpKltOpencv. - */ + /*! + * Get the current list of KLT points. + * + * \return the list of KLT points through vpKltOpencv. + */ inline std::vector getKltPoints() const { return tracker.getFeatures(); } std::vector getKltImagePoints() const; @@ -281,31 +280,31 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker std::map getKltImagePointsWithId() const; /*! - Get the klt tracker at the current state. - - \return klt tracker. + * Get the klt tracker at the current state. + * + * \return klt tracker. */ inline vpKltOpencv getKltOpencv() const { return tracker; } /*! - Get the erosion of the mask used on the Model faces. - - \return The erosion. + * Get the erosion of the mask used on the Model faces. + * + * \return The erosion. */ inline unsigned int getKltMaskBorder() const { return maskBorder; } /*! - Get the current number of klt points. - - \return the number of features + * Get the current number of klt points. + * + * \return the number of features */ inline int getKltNbPoints() const { return tracker.getNbFeatures(); } /*! - Get the threshold for the acceptation of a point. - - \return threshold_outlier : Threshold for the weight below which a point - is rejected. + * Get the threshold for the acceptation of a point. + * + * \return threshold_outlier : Threshold for the weight below which a point + * is rejected. */ inline double getKltThresholdAcceptation() const { return threshold_outlier; } @@ -321,15 +320,15 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker virtual void loadConfigFile(const std::string &configFile, bool verbose = true) override; virtual void reInitModel(const vpImage &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo, - bool verbose = false, const vpHomogeneousMatrix &T = vpHomogeneousMatrix()) override; + bool verbose = false, const vpHomogeneousMatrix &T = vpHomogeneousMatrix()); void resetTracker() override; void setCameraParameters(const vpCameraParameters &cam) override; /*! - Set the erosion of the mask used on the Model faces. - - \param e : The desired erosion. + * Set the erosion of the mask used on the Model faces. + * + * \param e : The desired erosion. */ inline void setKltMaskBorder(const unsigned int &e) { @@ -341,19 +340,19 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker virtual void setKltOpencv(const vpKltOpencv &t); /*! - Set the threshold for the acceptation of a point. - - \param th : Threshold for the weight below which a point is rejected. + * Set the threshold for the acceptation of a point. + * + * \param th : Threshold for the weight below which a point is rejected. */ inline void setKltThresholdAcceptation(double th) { threshold_outlier = th; } /*! - Use Ogre3D for visibility tests - - \warning This function has to be called before the initialization of the - tracker. - - \param v : True to use it, False otherwise + * Use Ogre3D for visibility tests + * + * \warning This function has to be called before the initialization of the + * tracker. + * + * \param v : True to use it, False otherwise */ virtual void setOgreVisibilityTest(const bool &v) override { @@ -364,9 +363,9 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker } /*! - Use Scanline algorithm for visibility tests - - \param v : True to use it, False otherwise + * Use Scanline algorithm for visibility tests + * + * \param v : True to use it, False otherwise */ virtual void setScanLineVisibilityTest(const bool &v) override { @@ -380,11 +379,11 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker virtual void setPose(const vpImage &I_color, const vpHomogeneousMatrix &cdMo) override; /*! - Set if the projection error criteria has to be computed. - - \param flag : True if the projection error criteria has to be computed, - false otherwise - */ + * Set if the projection error criteria has to be computed. + * + * \param flag : True if the projection error criteria has to be computed, + * false otherwise + */ virtual void setProjectionErrorComputation(const bool &flag) override { if (flag) @@ -405,32 +404,34 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker //@{ /*! - Get the erosion of the mask used on the Model faces. - \deprecated Use rather getkltMaskBorder() - - \return The erosion. + * Get the erosion of the mask used on the Model faces. + * \deprecated Use rather getkltMaskBorder() + * + * \return The erosion. */ /* vp_deprecated */ inline unsigned int getMaskBorder() const { return maskBorder; } - /*! - Get the current number of klt points. - \deprecated Use rather getKltNbPoints() - \return the number of features + /*! + * Get the current number of klt points. + * \deprecated Use rather getKltNbPoints() + * + * \return the number of features */ /* vp_deprecated */ inline int getNbKltPoints() const { return tracker.getNbFeatures(); } /*! - Get the threshold for the acceptation of a point. - \deprecated Use rather getKltThresholdAcceptation() - - \return threshold_outlier : Threshold for the weight below which a point - is rejected. + * Get the threshold for the acceptation of a point. + * \deprecated Use rather getKltThresholdAcceptation() + * + * \return threshold_outlier : Threshold for the weight below which a point + * is rejected. */ /* vp_deprecated */ inline double getThresholdAcceptation() const { return threshold_outlier; } - /*! - Set the erosion of the mask used on the Model faces. - \param e : The desired erosion. + /*! + * Set the erosion of the mask used on the Model faces. + * + * \param e : The desired erosion. */ /* vp_deprecated */ inline void setMaskBorder(const unsigned int &e) { @@ -440,10 +441,10 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker } /*! - Set the threshold for the acceptation of a point. - \deprecated Use rather setKltThresholdAcceptation() - - \param th : Threshold for the weight below which a point is rejected. + * Set the threshold for the acceptation of a point. + * \deprecated Use rather setKltThresholdAcceptation() + * + * \param th : Threshold for the weight below which a point is rejected. */ /* vp_deprecated */ inline void setThresholdAcceptation(double th) { threshold_outlier = th; }