35#ifndef VP_SILHOUETTE_CCD_TRACKER_H
36#define VP_SILHOUETTE_CCD_TRACKER_H
38#include <visp3/core/vpConfig.h>
39#include <visp3/core/vpColVector.h>
40#include <visp3/core/vpImage.h>
41#include <visp3/core/vpCameraParameters.h>
42#include <visp3/core/vpExponentialMap.h>
43#include <visp3/core/vpPixelMeterConversion.h>
44#include <visp3/core/vpMatrix.h>
45#include <visp3/core/vpHomogeneousMatrix.h>
46#include <visp3/core/vpRobust.h>
47#include <visp3/core/vpUniRand.h>
52#include <visp3/rbt/vpRBSilhouetteControlPoint.h>
53#include <visp3/rbt/vpRBFeatureTracker.h>
59#if defined(VISP_HAVE_NLOHMANN_JSON)
60#include VISP_NLOHMANN_JSON(json.hpp)
140#if defined(VISP_HAVE_NLOHMANN_JSON)
141inline void from_json(
const nlohmann::json &j,
vpCCDParameters &ccdParameters)
143 ccdParameters.
alpha = j.value(
"alpha", ccdParameters.
alpha);
144 ccdParameters.
beta = j.value(
"beta", ccdParameters.
beta);
145 ccdParameters.
kappa = j.value(
"kappa", ccdParameters.
kappa);
148 ccdParameters.
h = j.value(
"h", ccdParameters.
h);
149 ccdParameters.
start_h = ccdParameters.
h;
150 ccdParameters.
delta_h = j.value(
"delta_h", ccdParameters.
delta_h);
152 if (j.contains(
"min_h")) {
153 ccdParameters.
min_h = j.value(
"min_h", ccdParameters.
min_h);
156 ccdParameters.
min_h = ccdParameters.
h;
160 if (
j.contains(
"gamma")) {
161 nlohmann::json gammaj =
j[
"gamma"];
162 if (!gammaj.is_array() || gammaj.size() != 4) {
165 ccdParameters.
gamma_1 = gammaj[0];
166 ccdParameters.
gamma_2 = gammaj[1];
167 ccdParameters.
gamma_3 = gammaj[2];
168 ccdParameters.
gamma_4 = gammaj[3];
182 void reinit(
int resolution,
unsigned normalPointsNumber)
184 nv.resize(resolution, 2,
false,
false);
185 mean_vic.resize(resolution, 6,
false,
false);
186 cov_vic.resize(resolution, 18,
false,
false);
187 vic.resize(resolution, 20 * normalPointsNumber,
false,
false);
188 imgPoints.resize(resolution, 2 * 3 * normalPointsNumber,
false,
false);
338 void buildGradientAndHessianStorageViews(
unsigned int normalsPerPoint,
bool clear);
346#if defined(VISP_HAVE_NLOHMANN_JSON)
348#if defined(__clang__)
351# pragma clang diagnostic push
352# pragma clang diagnostic ignored "-Wexit-time-destructors"
376#if defined(__clang__)
377# pragma clang diagnostic pop
385 template<
bool hasTemporalSmoothing>
double gamma_2
Curve uncertainty computation hyperparameter. Recommended to leave fixed.
double gamma_3
Curve uncertainty computation hyperparameter. Recommended to leave fixed.
double gamma_1
Curve uncertainty computation hyperparameter. Recommended to leave fixed.
double covarianceIterDecreaseFactor
From the CCD paper: maximum decrease of the covariance within one iteration step. Between 0 and 1 If ...
int delta_h
Sample step when computing statistics and errors. Increase this value to decrease computation time,...
~vpCCDParameters()=default
int min_iters_before_scale_change
int phi_dim
Number of parameters estimated by CCD. Either 6 or 8. Leave this fixed.
int h
Size of the vicinity that is used to compute statistics and error. Length of the line along the norma...
double gamma_4
Curve uncertainty computation hyperparameter. Recommended to leave fixed.
int iters_since_scale_change
double kappa
Bias to the diagonal of the covariance of the color statistics of a single pixel. Used to avoid singu...
vpMatrix imgPoints
Normal vector.
vpMatrix mean_vic
Vicinity data.
void reinit(int resolution, unsigned normalPointsNumber)
Img pixels.
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
Implementation of a matrix and operations on matrices.
std::shared_ptr< vpTemporalWeighting > m_weighting
Number of considered features.
virtual void loadJsonConfiguration(const nlohmann::json &j)
bool m_vvsConverged
User-defined weight for this specific type of feature.
vpMatrix m_cov
Right side of the Gauss Newton minimization.
Tracking based on the Contracting Curve Density algorithm.
void setTemporalSmoothingFactor(double factor)
Sets the temporal smoothing factor.
const vpRBFeatureTrackerInput * m_previousFrame
unsigned int getMaxNumPoints() const
Get the maximum number of silhouette control points that will be used by the tracker at a given itera...
void onTrackingIterEnd(const vpHomogeneousMatrix &) VP_OVERRIDE
Method called after the tracking iteration has finished.
bool requiresSilhouetteCandidates() const VP_OVERRIDE
Whether this tracker requires Silhouette candidates.
vpRobust m_robust
Silhouette points where to compute CCD statistics.
vpRBSilhouetteCCDTracker()
void setCCDParameters(const vpCCDParameters ¶meters)
vpCCDStatistics m_prevStats
bool requiresDepth() const VP_OVERRIDE
Whether this tracker requires depth image to extract features.
double m_minMaskConfidence
bool requiresRGB() const VP_OVERRIDE
Whether this tracker requires RGB image to extract features.
NLOHMANN_JSON_SERIALIZE_ENUM(vpRBSilhouetteCCDTracker::vpDisplayType, { {vpRBSilhouetteCCDTracker::vpDisplayType::DT_INVALID, nullptr}, {vpRBSilhouetteCCDTracker::vpDisplayType::DT_SIMPLE, "simple"}, {vpRBSilhouetteCCDTracker::vpDisplayType::DT_WEIGHT, "weight"}, {vpRBSilhouetteCCDTracker::vpDisplayType::DT_ERROR, "error"}, {vpRBSilhouetteCCDTracker::vpDisplayType::DT_WEIGHT_AND_ERROR, "weightAndError"} })
double getTemporalSmoothingFactor() const
Returns the amount of temporal smoothing applied when computing the tracking error and its jacobian....
void trackFeatures(const vpRBFeatureTrackerInput &, const vpRBFeatureTrackerInput &, const vpHomogeneousMatrix &) VP_OVERRIDE
Track the features.
void setDisplayType(vpDisplayType type)
double getMinimumMaskConfidence() const
Returns the minimum mask gradient required for a silhouette point to be considered.
virtual void loadJsonConfiguration(const nlohmann::json &j) VP_OVERRIDE
std::vector< double > m_hessianData
double getVVSTrackerWeight(double optimizationProgress) const VP_OVERRIDE
Get the importance of this tracker in the optimization step. The default computation is the following...
vpDisplayType m_displayType
std::vector< vpColVector > m_gradients
std::vector< double > m_gradientData
void updateCovariance(const double) VP_OVERRIDE
Update the covariance matrix.
void setShouldUseMask(bool useMask)
double m_temporalSmoothingFac
Sum of local hessians.
std::vector< vpRBSilhouetteControlPoint > m_controlPoints
bool shouldUseMask() const
Returns whether the tracking algorithm should filter out points that are unlikely to be on the object...
void setMaxNumPoints(unsigned int maxPoints)
vpCCDParameters m_ccdParameters
static const unsigned int BASE_SEED
vpMatrix m_hessian
Sum of local gradients.
std::vector< vpMatrix > m_hessians
bool m_useMask
Smoothing factor used to integrate data from the previous frame.
double m_vvsConvergenceThreshold
virtual ~vpRBSilhouetteCCDTracker()=default
void setMinimumMaskConfidence(double confidence)
void reset() VP_OVERRIDE
Resets feature state. Can be called when the object changes or is lost, Ensuring that prior data does...
vpCCDParameters getCCDParameters() const
Contains an M-estimator and various influence function.
Class for generating random numbers with uniform probability density.