Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpRBSilhouetteMeTracker.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 */
30
35#ifndef VP_RB_SILHOUETTE_ME_TRACKER_H
36#define VP_RB_SILHOUETTE_ME_TRACKER_H
37
38#include <visp3/rbt/vpRBFeatureTracker.h>
39#include <visp3/rbt/vpRBSilhouetteControlPoint.h>
40#include <visp3/core/vpRobust.h>
41
56{
57public:
58
60 vpRBFeatureTracker(), m_me(), m_numCandidates(1), m_robustMadMin(1.0), m_globalVVSConvergenceThreshold(1.0),
61 m_singlePointConvergedThresholdPixels(3), m_useMask(false), m_minMaskConfidence(0.f)
62 { }
63
64 virtual ~vpRBSilhouetteMeTracker() = default;
65
66 bool requiresRGB() const VP_OVERRIDE { return false; }
67
68 bool requiresDepth() const VP_OVERRIDE { return false; }
69
70 bool requiresSilhouetteCandidates() const VP_OVERRIDE { return true; }
71
72 void setMovingEdge(const vpMe &me) { m_me = me; }
73
74 void onTrackingIterStart(const vpRBFeatureTrackerInput &/*frame*/, const vpHomogeneousMatrix & /*cMo*/) VP_OVERRIDE
75 {
76 m_controlPoints.clear();
77 }
78
79 void onTrackingIterEnd(const vpHomogeneousMatrix & /*cMo*/) VP_OVERRIDE { }
80
84 void extractFeatures(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, const vpHomogeneousMatrix &cMo) VP_OVERRIDE;
85
86 void trackFeatures(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, const vpHomogeneousMatrix &cMo) VP_OVERRIDE;
87
88 void initVVS(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, const vpHomogeneousMatrix &cMo) VP_OVERRIDE;
89
90 void computeVVSIter(const vpRBFeatureTrackerInput &frame, const vpHomogeneousMatrix &cMo, unsigned int iteration) VP_OVERRIDE;
91
92 void display(const vpCameraParameters &cam, const vpImage<unsigned char> &I, const vpImage<vpRGBa> &IRGB, const vpImage<unsigned char> &depth) const VP_OVERRIDE;
93
98 const vpMe &getMe() const { return m_me; }
99 vpMe &getMe() { return m_me; }
100
101 unsigned int getNumCandidates() const { return m_numCandidates; }
102 void setNumCandidates(unsigned int candidates)
103 {
104 if (candidates == 0) {
105 throw vpException(vpException::badValue, "Cannot set a number of candidates equal to zero");
106 }
107 m_numCandidates = candidates;
108 }
109
110 double getMinRobustThreshold() const { return m_robustMadMin; }
111 void setMinRobustThreshold(double threshold)
112 {
113 if (threshold < 0) {
114 throw vpException(vpException::badValue, "Robust M estimator min threshold should be greater or equal to 0.");
115 }
116 m_robustMadMin = threshold;
117 }
118
124 bool shouldUseMask() const { return m_useMask; }
125 void setShouldUseMask(bool useMask) { m_useMask = useMask; }
126
133 float getMinimumMaskConfidence() const { return m_minMaskConfidence; }
134 void setMinimumMaskConfidence(float confidence)
135 {
136 if (confidence > 1.f || confidence < 0.f) {
137 throw vpException(vpException::badValue, "Mask confidence should be between 0 and 1");
138 }
139 m_minMaskConfidence = confidence;
140 }
141
142 double getSinglePointConvergenceThreshold() const { return m_singlePointConvergedThresholdPixels; }
144 {
145 if (threshold < 0.0) {
146 throw vpException(vpException::badValue, "Convergence threshold should be null or positive");
147 }
148 m_singlePointConvergedThresholdPixels = threshold;
149 }
150
151 double getGlobalConvergenceMinimumRatio() const { return m_globalVVSConvergenceThreshold; }
152 void setGlobalConvergenceMinimumRatio(double threshold)
153 {
154 if (threshold < 0.0 || threshold > 1.0) {
155 throw vpException(vpException::badValue, "Minimum converged ratio be between 0 and 1");
156 }
157 m_globalVVSConvergenceThreshold = threshold;
158 }
159
160#if defined(VISP_HAVE_NLOHMANN_JSON)
161 virtual void loadJsonConfiguration(const nlohmann::json &j) VP_OVERRIDE
162 {
164 setNumCandidates(j.value("numCandidates", m_numCandidates));
165 setSinglePointConvergenceThreshold(j.value("convergencePixelThreshold", m_singlePointConvergedThresholdPixels));
166 setGlobalConvergenceMinimumRatio(j.value("convergenceRatio", m_globalVVSConvergenceThreshold));
167 m_me = j.value("movingEdge", m_me);
168 setShouldUseMask(j.value("useMask", m_useMask));
169 setMinimumMaskConfidence(j.value("minMaskConfidence", m_minMaskConfidence));
170 // m_me.setThresholdMarginRatio(-1.0);
171 // m_me.setMinThreshold(-1.0);
172 }
173#endif
174
179
180private:
181
182 std::vector<vpRBSilhouetteControlPoint> m_controlPoints;
183 vpMe m_me;
184 unsigned int m_numCandidates;
185 vpRobust m_robust;
186 double m_robustMadMin;
187 double m_globalVVSConvergenceThreshold;
188 double m_singlePointConvergedThresholdPixels;
189 bool m_useMask;
190 float m_minMaskConfidence;
191};
192
193END_VISP_NAMESPACE
194
195#endif
Generic class defining intrinsic camera parameters.
error that can be emitted by ViSP classes.
Definition vpException.h:60
@ badValue
Used to indicate that a value is not in the allowed range.
Definition vpException.h:73
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
Definition vpImage.h:131
Definition vpMe.h:143
All the data related to a single tracking frame. This contains both the input data (from a real camer...
virtual void extractFeatures(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, const vpHomogeneousMatrix &cMo)=0
Extract features from the frame data and the current pose estimate.
virtual void trackFeatures(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, const vpHomogeneousMatrix &cMo)=0
Track the features.
virtual void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpImage< vpRGBa > &IRGB, const vpImage< unsigned char > &depth) const =0
virtual void loadJsonConfiguration(const nlohmann::json &j)
virtual void initVVS(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, const vpHomogeneousMatrix &cMo)=0
virtual void computeVVSIter(const vpRBFeatureTrackerInput &frame, const vpHomogeneousMatrix &cMo, unsigned int iteration)=0
bool requiresRGB() const VP_OVERRIDE
Whether this tracker requires RGB image to extract features.
virtual ~vpRBSilhouetteMeTracker()=default
virtual void loadJsonConfiguration(const nlohmann::json &j) VP_OVERRIDE
void setNumCandidates(unsigned int candidates)
double getSinglePointConvergenceThreshold() const
void setMinimumMaskConfidence(float confidence)
float getMinimumMaskConfidence() const
Returns the minimum mask confidence that a pixel linked to depth point should have if it should be ke...
void setSinglePointConvergenceThreshold(double threshold)
bool shouldUseMask() const
Returns whether the tracking algorithm should filter out points that are unlikely to be on the object...
double getGlobalConvergenceMinimumRatio() const
void onTrackingIterEnd(const vpHomogeneousMatrix &) VP_OVERRIDE
Method called after the tracking iteration has finished.
void setGlobalConvergenceMinimumRatio(double threshold)
void setMovingEdge(const vpMe &me)
bool requiresSilhouetteCandidates() const VP_OVERRIDE
Whether this tracker requires Silhouette candidates.
unsigned int getNumCandidates() const
void setMinRobustThreshold(double threshold)
void onTrackingIterStart(const vpRBFeatureTrackerInput &, const vpHomogeneousMatrix &) VP_OVERRIDE
Method called when starting a tracking iteration.
bool requiresDepth() const VP_OVERRIDE
Whether this tracker requires depth image to extract features.
Contains an M-estimator and various influence function.
Definition vpRobust.h:84