35#ifndef VP_RB_TRACKER_H
36#define VP_RB_TRACKER_H
38#include <visp3/core/vpConfig.h>
40#if defined(VISP_HAVE_PANDA3D)
42#include <visp3/rbt/vpRBFeatureTracker.h>
43#include <visp3/rbt/vpRBSilhouettePointsExtractionSettings.h>
44#include <visp3/rbt/vpPanda3DDepthFilters.h>
45#include <visp3/rbt/vpObjectCentricRenderer.h>
46#include <visp3/rbt/vpRBTrackingResult.h>
47#include <visp3/rbt/vpRBConvergenceMetric.h>
48#include <visp3/rbt/vpRBInitializationHelper.h>
49#include <visp3/core/vpDisplay.h>
54#if defined(VISP_HAVE_NLOHMANN_JSON)
55#include VISP_NLOHMANN_JSON(json_fwd.hpp)
148 void addTracker(std::shared_ptr<vpRBFeatureTracker> tracker);
167 void setModelPath(
const std::string &path);
284#if defined(VISP_HAVE_NLOHMANN_JSON)
293 void loadConfigurationFile(
const std::string &filename);
301 void loadConfiguration(
const nlohmann::json &j);
322 void startTracking();
405#ifdef VISP_HAVE_MODULE_GUI
425 template <
typename ImageType>
426 typename std::enable_if<std::is_same<ImageType, unsigned char>::value || std::is_same<ImageType, vpRGBa>::value,
void >::type
initClick(
const vpImage<ImageType> &I,
const std::string &initFile,
bool displayHelp)
430 initializer.initClick(I, initFile, displayHelp, *
this);
467 template <
typename T>
473 for (
unsigned int r = std::max(bb.getTop(), 0.); (r < bb.getBottom()) &&(r < I.getRows()); ++r) {
474 for (
unsigned int c = std::max(bb.getLeft(), 0.); (c < bb.getRight()) && (c < I.getCols()); ++c) {
475 if (Isilhouette[r][c] != 0) {
495 std::vector<vpRBSilhouettePoint> extractSilhouettePoints(
511 std::stringstream ss;
512 ss <<
"vpRBTracker: dimension error: expected " << imgType;
514 ss <<
", but got " << I.getCols() <<
" x " << I.getRows();
Generic class defining intrinsic camera parameters.
static const vpColor green
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
@ dimensionError
Bad dimension.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
Implementation of a matrix and operations on matrices.
Single object focused renderer.
Implementation of canny filtering, using Sobel kernels.
Rendering parameters for a panda3D simulation.
Base interface for algorithms that should detect tracking drift for the render-based tracker.
vpHomogeneousMatrix getPose() const
void setCameraParameters(const vpCameraParameters &cam)
bool m_displaySilhouette
Metric used to compare the motion between different poses.
std::shared_ptr< vpRBDriftDetector > m_driftDetector
std::shared_ptr< vpRBVisualOdometry > m_odometry
vpSilhouettePointsExtractionSettings m_depthSilhouetteSettings
Settings for silhouette extraction.
vpCameraParameters m_cam
Camera intrinsics.
void checkDimensionsOrThrow(const vpImage< T > &I, const std::string &imgType) const
Check that a given image has the correct dimensions, previously specified with setCameraParameters or...
double getOptimizationInitialMu() const
vpObjectCentricRenderer m_renderer
3D renderer
unsigned int getImageWidth() const
unsigned m_vvsIterations
Maximum number of optimization iterations.
std::shared_ptr< vpRBDriftDetector > getDriftDetector() const
bool m_firstIteration
Whether this is the first iteration.
void setScaleInvariantRegularization(bool invariant)
double m_muIterFactor
Factor with which to multiply mu at every iteration during optimization.
void updateRender(vpRBFeatureTrackerInput &frame)
Update the render data with a render at the last tracked pose.
std::vector< std::shared_ptr< vpRBFeatureTracker > > m_trackers
List of feature trackers.
std::string m_modelPath
Location of the 3D model to load.
vpPanda3DRenderParameters m_rendererSettings
Camera specific setup for the 3D Panda renderer.
std::shared_ptr< vpRBVisualOdometry > getOdometryMethod() const
double getOptimizationMuIterFactor() const
friend vpRBInitializationHelper
std::shared_ptr< vpRBConvergenceMetric > m_convergenceMetric
unsigned m_imageHeight
Color and render image dimensions.
bool scaleInvariantRegularization() const
double m_lambda
Optimization gain.
void getPose(vpHomogeneousMatrix &cMo) const
Get the estimated pose of the object in the camera frame.
std::shared_ptr< vpObjectMask > m_mask
vpRBTrackingResult track(const vpImage< unsigned char > &I)
track and re-estimate the pose of the object in this frame, given only a grayscale image The pose aft...
vpHomogeneousMatrix m_cMoPrev
Previous pose of the object in the camera frame.
bool shouldRenderSilhouette()
Returns whether the renderer should render the silhouette information.
void setDriftDetector(const std::shared_ptr< vpRBDriftDetector > &detector)
Sets the method to perform drift detection and estimate tracking confidence. Set to null to disable t...
vpRBFeatureTrackerInput m_currentFrame
void setOdometryMethod(const std::shared_ptr< vpRBVisualOdometry > &odometry)
Set the method to use when performing visual odometry to preestimate the camera motion before trackin...
unsigned int getImageHeight() const
double getOptimizationGain() const
void setupRenderer(const std::string &file)
Setup the renderer, and load the 3D model.
vpRBFeatureTrackerInput m_previousFrame
vpObjectCentricRenderer & getRenderer()
Get the renderer used to render the object.
unsigned int getMaxOptimizationIters() const
const vpRBFeatureTrackerInput & getMostRecentFrame() const
Retrieve the most recent frame that was used when tracking the object. The renders may not correspond...
std::enable_if< std::is_same< ImageType, unsignedchar >::value||std::is_same< ImageType, vpRGBa >::value, void >::type initClick(const vpImage< ImageType > &I, const std::string &initFile, bool displayHelp)
Perform Pose initialization by asking the user to click on predefined 3D points. This method is simil...
std::shared_ptr< vpObjectMask > getObjectSegmentationMethod() const
void setOptimizationMuIterFactor(double factor)
void setOptimizationInitialMu(double mu)
void setOptimizationGain(double lambda)
double m_muInit
Initial mu value for Levenberg-Marquardt.
std::string getModelPath() const
Get the path to the 3D model to track.
void setPose(const vpHomogeneousMatrix &cMo)
Sets the pose of the object in the camera frame. Should be called when initializing the tracker or wh...
std::vector< std::shared_ptr< vpRBFeatureTracker > > getFeatureTrackers() const
Get the tracked features.
vpSilhouettePointsExtractionSettings getSilhouetteExtractionParameters() const
void setObjectSegmentationMethod(const std::shared_ptr< vpObjectMask > &mask)
Sets the algorithm to use when performing object segmentation. Set to null to disable the use of segm...
vpHomogeneousMatrix m_cMo
Current pose of the object in the camera frame.
bool m_scaleInvariantOptim
Whether to use diagonal scaling in Levenberg-Marquardt regularization.
void setMaxOptimizationIters(unsigned int iters)
void displaySilhouette(const vpImage< T > &I, const vpRBFeatureTrackerInput &frame)
Display the object silhouette of the frame in I.
Defines a rectangle in the plane.
vpImage< unsigned char > isSilhouette
Image containing the orientation of the gradients.