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>
51 #include <visp3/rbt/vpRBSilhouetteControlPoint.h>
52 #include <visp3/rbt/vpRBFeatureTracker.h>
58 #if defined(VISP_HAVE_NLOHMANN_JSON)
59 #include VISP_NLOHMANN_JSON(json.hpp)
65 enum vpRBSilhouetteCCDDisplayType
76 vpCCDParameters() : gamma_1(0.5), gamma_2(4), gamma_3(4), gamma_4(3), alpha(1.3), beta(0.06), kappa(0.5), covarianceIterDecreaseFactor(0.25), h(40), delta_h(1), phi_dim(6)
141 #if defined(VISP_HAVE_NLOHMANN_JSON)
142 inline void from_json(
const nlohmann::json &j,
vpCCDParameters &ccdParameters)
144 ccdParameters.
alpha = j.value(
"alpha", ccdParameters.
alpha);
145 ccdParameters.
beta = j.value(
"beta", ccdParameters.
beta);
146 ccdParameters.
kappa = j.value(
"kappa", ccdParameters.
kappa);
149 ccdParameters.
h = j.value(
"h", ccdParameters.
h);
150 ccdParameters.
delta_h = j.value(
"delta_h", ccdParameters.
delta_h);
151 ccdParameters.
phi_dim = j.value(
"phi_dim", ccdParameters.
phi_dim);
152 if (j.contains(
"gamma")) {
153 nlohmann::json gammaj = j[
"gamma"];
154 if (!gammaj.is_array() || gammaj.size() != 4) {
157 ccdParameters.
gamma_1 = gammaj[0];
158 ccdParameters.
gamma_2 = gammaj[1];
159 ccdParameters.
gamma_3 = gammaj[2];
160 ccdParameters.
gamma_4 = gammaj[3];
175 void reinit(
int resolution,
unsigned normalPointsNumber)
177 nv.
resize(resolution, 2,
false,
false);
178 mean_vic.
resize(resolution, 6,
false,
false);
179 cov_vic.
resize(resolution, 18,
false,
false);
180 vic.
resize(resolution, 20 * normalPointsNumber,
false,
false);
181 imgPoints.
resize(resolution, 2 * 3 * normalPointsNumber,
false,
false);
182 weight.
resize(resolution, 2 * normalPointsNumber,
false,
false);
228 m_temporalSmoothingFac = factor;
248 m_minMaskConfidence = confidence;
253 m_displayType = type;
277 #if defined(VISP_HAVE_NLOHMANN_JSON)
282 m_vvsConvergenceThreshold = j.value(
"convergenceThreshold", m_vvsConvergenceThreshold);
283 setTemporalSmoothingFactor(j.value(
"temporalSmoothing", m_temporalSmoothingFac));
284 setShouldUseMask(j.value(
"useMask", m_useMask));
285 setMinimumMaskConfidence(j.value(
"minMaskConfidence", m_minMaskConfidence));
287 m_ccdParameters = j.value(
"ccd", m_ccdParameters);
295 void computeErrorAndInteractionMatrix();
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
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 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.
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)
Whether this pixel is the object.
vpMatrix weight
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.
Implementation of a matrix and operations on matrices.
A base class for all features that can be used and tracked in the vpRBTracker.
virtual void loadJsonConfiguration(const nlohmann::json &j)
Tracking based on the Contracting Curve Density algorithm.
void setTemporalSmoothingFactor(double factor)
Sets the temporal smoothing factor.
bool requiresSilhouetteCandidates() const VP_OVERRIDE
Whether this tracker requires Silhouette candidates.
vpRobust m_robust
Silhouette points where to compute CCD statistics.
void setCCDParameters(const vpCCDParameters ¶meters)
vpCCDStatistics m_prevStats
double getVVSTrackerWeight() const VP_OVERRIDE
Get the importance of this tracker in the optimization step. The default computation is the following...
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.
double getTemporalSmoothingFactor() const
Returns the amount of temporal smoothing applied when computing the tracking error and its jacobian....
vpRBSilhouetteCCDDisplayType m_displayType
void trackFeatures(const vpRBFeatureTrackerInput &, const vpRBFeatureTrackerInput &, const vpHomogeneousMatrix &) VP_OVERRIDE
Track the features.
void setMinimumMaskConfidence(float confidence)
void onTrackingIterStart() VP_OVERRIDE
Method called when starting a tracking iteration.
virtual void loadJsonConfiguration(const nlohmann::json &j) VP_OVERRIDE
void setDisplayType(vpRBSilhouetteCCDDisplayType type)
void onTrackingIterEnd() VP_OVERRIDE
Method called after the tracking iteration has finished.
std::vector< vpColVector > m_gradients
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...
vpCCDParameters m_ccdParameters
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
float getMinimumMaskConfidence() const
Returns the minimum mask gradient required for a silhouette point to be considered.
vpCCDParameters getCCDParameters() const
Trackable silhouette point representation.
Contains an M-estimator and various influence function.