38 #include <visp3/vision/vpPoseFeatures.h> 40 #ifdef VISP_HAVE_MODULE_VISUAL_FEATURES 46 : maxSize(0), totalSize(0), vvsIterMax(200), lambda(1.0), verbose(false), computeCovariance(false),
47 covarianceMatrix(), featurePoint_Point_list(), featurePoint3D_Point_list(), featureVanishingPoint_Point_list(),
48 featureVanishingPoint_DuoLine_list(), featureEllipse_Sphere_list(), featureEllipse_Circle_list(),
49 featureLine_Line_list(), featureLine_DuoLineInt_List(), featureSegment_DuoPoints_list()
63 for (
int i = (
int)featurePoint_Point_list.size() - 1; i >= 0; i--)
64 delete featurePoint_Point_list[(
unsigned int)i].desiredFeature;
65 featurePoint_Point_list.clear();
67 for (
int i = (
int)featurePoint3D_Point_list.size() - 1; i >= 0; i--)
68 delete featurePoint3D_Point_list[(
unsigned int)i].desiredFeature;
69 featurePoint3D_Point_list.clear();
71 for (
int i = (
int)featureVanishingPoint_Point_list.size() - 1; i >= 0; i--)
72 delete featureVanishingPoint_Point_list[(
unsigned int)i].desiredFeature;
73 featureVanishingPoint_Point_list.clear();
75 for (
int i = (
int)featureVanishingPoint_DuoLine_list.size() - 1; i >= 0; i--)
76 delete featureVanishingPoint_DuoLine_list[(
unsigned int)i].desiredFeature;
77 featureVanishingPoint_DuoLine_list.clear();
79 for (
int i = (
int)featureEllipse_Sphere_list.size() - 1; i >= 0; i--)
80 delete featureEllipse_Sphere_list[(
unsigned int)i].desiredFeature;
81 featureEllipse_Sphere_list.clear();
83 for (
int i = (
int)featureEllipse_Circle_list.size() - 1; i >= 0; i--)
84 delete featureEllipse_Circle_list[(
unsigned int)i].desiredFeature;
85 featureEllipse_Circle_list.clear();
87 for (
int i = (
int)featureLine_Line_list.size() - 1; i >= 0; i--)
88 delete featureLine_Line_list[(
unsigned int)i].desiredFeature;
89 featureLine_Line_list.clear();
91 for (
int i = (
int)featureLine_DuoLineInt_List.size() - 1; i >= 0; i--)
92 delete featureLine_DuoLineInt_List[(
unsigned int)i].desiredFeature;
93 featureLine_DuoLineInt_List.clear();
95 for (
int i = (
int)featureSegment_DuoPoints_list.size() - 1; i >= 0; i--)
96 delete featureSegment_DuoPoints_list[(
unsigned int)i].desiredFeature;
97 featureSegment_DuoPoints_list.clear();
99 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 100 for (
int i = (
int)featureSpecific_list.size() - 1; i >= 0; i--)
101 delete featureSpecific_list[(
unsigned int)i];
102 featureSpecific_list.clear();
117 featurePoint_Point_list.push_back(vpDuo<vpFeaturePoint, vpPoint>());
118 featurePoint_Point_list.back().firstParam = p;
119 featurePoint_Point_list.back().desiredFeature =
new vpFeaturePoint();
123 if (featurePoint_Point_list.size() > maxSize)
124 maxSize = (
unsigned int)featurePoint_Point_list.size();
135 featurePoint3D_Point_list.push_back(vpDuo<vpFeaturePoint3D, vpPoint>());
136 featurePoint3D_Point_list.back().firstParam = p;
141 if (featurePoint3D_Point_list.size() > maxSize)
142 maxSize = (
unsigned int)featurePoint3D_Point_list.size();
153 featureVanishingPoint_Point_list.push_back(vpDuo<vpFeatureVanishingPoint, vpPoint>());
154 featureVanishingPoint_Point_list.back().firstParam = p;
159 if (featureVanishingPoint_Point_list.size() > maxSize)
160 maxSize = (
unsigned int)featureVanishingPoint_Point_list.size();
172 featureVanishingPoint_DuoLine_list.push_back(vpTrio<vpFeatureVanishingPoint, vpLine, vpLine>());
173 featureVanishingPoint_DuoLine_list.back().firstParam = l1;
174 featureVanishingPoint_DuoLine_list.back().secondParam = l2;
179 if (featureVanishingPoint_DuoLine_list.size() > maxSize)
180 maxSize = (
unsigned int)featureVanishingPoint_DuoLine_list.size();
191 featureEllipse_Sphere_list.push_back(vpDuo<vpFeatureEllipse, vpSphere>());
192 featureEllipse_Sphere_list.back().firstParam = s;
197 if (featureEllipse_Sphere_list.size() > maxSize)
198 maxSize = (
unsigned int)featureEllipse_Sphere_list.size();
209 featureEllipse_Circle_list.push_back(vpDuo<vpFeatureEllipse, vpCircle>());
210 featureEllipse_Circle_list.back().firstParam = c;
215 if (featureEllipse_Circle_list.size() > maxSize)
216 maxSize = (
unsigned int)featureEllipse_Circle_list.size();
227 featureLine_Line_list.push_back(vpDuo<vpFeatureLine, vpLine>());
228 featureLine_Line_list.back().firstParam = l;
229 featureLine_Line_list.back().desiredFeature =
new vpFeatureLine();
233 if (featureLine_Line_list.size() > maxSize)
234 maxSize = (
unsigned int)featureLine_Line_list.size();
247 featureLine_DuoLineInt_List.push_back(vpTrio<vpFeatureLine, vpCylinder, int>());
248 featureLine_DuoLineInt_List.back().firstParam = c;
249 featureLine_DuoLineInt_List.back().secondParam = line;
250 featureLine_DuoLineInt_List.back().desiredFeature =
new vpFeatureLine();
254 if (featureLine_DuoLineInt_List.size() > maxSize)
255 maxSize = (
unsigned int)featureLine_DuoLineInt_List.size();
267 featureSegment_DuoPoints_list.push_back(vpTrio<vpFeatureSegment, vpPoint, vpPoint>());
268 featureSegment_DuoPoints_list.back().firstParam = P1;
269 featureSegment_DuoPoints_list.back().secondParam = P2;
270 featureSegment_DuoPoints_list.back().desiredFeature =
new vpFeatureSegment();
274 if (featureSegment_DuoPoints_list.size() > maxSize)
275 maxSize = (
unsigned int)featureSegment_DuoPoints_list.size();
290 for (
unsigned int i = 0; i < maxSize; i++) {
293 if (i < featurePoint_Point_list.size()) {
295 vpPoint p(featurePoint_Point_list[i].firstParam);
298 err.
stack(fp.
error(*(featurePoint_Point_list[i].desiredFeature)));
304 if (i < featurePoint3D_Point_list.size()) {
306 vpPoint p(featurePoint3D_Point_list[i].firstParam);
309 err.
stack(fp3D.
error(*(featurePoint3D_Point_list[i].desiredFeature)));
315 if (i < featureVanishingPoint_Point_list.size()) {
317 vpPoint p(featureVanishingPoint_Point_list[i].firstParam);
320 err.
stack(fvp.
error(*(featureVanishingPoint_Point_list[i].desiredFeature)));
324 if (i < featureVanishingPoint_DuoLine_list.size()) {
326 vpLine l1(featureVanishingPoint_DuoLine_list[i].firstParam);
327 vpLine l2(featureVanishingPoint_DuoLine_list[i].secondParam);
331 err.
stack(fvp.
error(*(featureVanishingPoint_DuoLine_list[i].desiredFeature)));
337 if (i < featureEllipse_Sphere_list.size()) {
339 vpSphere s(featureEllipse_Sphere_list[i].firstParam);
342 err.
stack(fe.
error(*(featureEllipse_Sphere_list[i].desiredFeature)));
346 if (i < featureEllipse_Circle_list.size()) {
348 vpCircle c(featureEllipse_Circle_list[i].firstParam);
351 err.
stack(fe.
error(*(featureEllipse_Circle_list[i].desiredFeature)));
357 if (i < featureLine_Line_list.size()) {
359 vpLine l(featureLine_Line_list[i].firstParam);
362 err.
stack(fl.
error(*(featureLine_Line_list[i].desiredFeature)));
366 if (i < featureLine_DuoLineInt_List.size()) {
368 vpCylinder c(featureLine_DuoLineInt_List[i].firstParam);
371 err.
stack(fl.
error(*(featureLine_DuoLineInt_List[i].desiredFeature)));
377 if (i < featureSegment_DuoPoints_list.size()) {
379 vpPoint p1(featureSegment_DuoPoints_list[i].firstParam);
380 vpPoint p2(featureSegment_DuoPoints_list[i].secondParam);
384 err.
stack(fs.
error(*(featureSegment_DuoPoints_list[i].desiredFeature)));
388 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 390 if (i < featureSpecific_list.size()) {
391 featureSpecific_list[i]->createCurrent(cMo);
392 err.
stack(featureSpecific_list[i]->error());
393 L.
stack(featureSpecific_list[i]->currentInteraction());
420 computePoseRobustVVS(cMo);
442 double residu_1 = 1e8;
450 unsigned int iter = 0;
453 while (std::fabs((residu_1 - r) * 1e12) > std::numeric_limits<double>::epsilon()) {
457 error_and_interaction(cMo, err, L);
468 vpTRACE(
"Rank must be at least 6 ! cMo not computed.");
474 v = -lambda * Lp * err;
477 if (iter++ > vvsIterMax) {
478 vpTRACE(
"Max iteration reached");
483 if (computeCovariance)
501 double residu_1 = 1e8;
513 unsigned int iter = 0;
516 while (std::fabs((residu_1 - r) * 1e12) > std::numeric_limits<double>::epsilon()) {
520 error_and_interaction(cMo, error, L);
532 for (
unsigned int k = 0; k < error.
getRows() / 2; k++) {
539 for (
unsigned int k = 0; k < error.
getRows() / 2; k++) {
540 W[2 * k][2 * k] = w[k];
541 W[2 * k + 1][2 * k + 1] = w[k];
546 (W * L).pseudoInverse(Lp, 1e-6);
551 vpTRACE(
"Rank must be at least 6 ! cMo not computed.");
557 v = -lambda * Lp * W * error;
561 if (iter++ > vvsIterMax) {
562 vpTRACE(
"Max iteration reached");
567 if (computeCovariance)
578 #endif //#ifdef VISP_HAVE_MODULE_VISUAL_FEATURES Implementation of a matrix and operations on matrices.
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
void addFeatureSegment(vpPoint &, vpPoint &)
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Compute the weights according a residue vector and a PsiFunction.
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true, const bool recopy_=true)
Class that defines 2D vanishing point visual feature (Z coordinate in 3D space is infinity)...
void stack(const vpMatrix &A)
void track(const vpHomogeneousMatrix &cMo)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
void addFeatureVanishingPoint(const vpPoint &)
Class that defines what is a sphere.
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b)
void addFeaturePoint3D(const vpPoint &)
void addFeaturePoint(const vpPoint &)
Class that defines what is a point.
void addFeatureEllipse(const vpCircle &)
virtual ~vpPoseFeatures()
void computePose(vpHomogeneousMatrix &cMo, const vpPoseFeaturesMethodType &type=VIRTUAL_VS)
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
Class that defines a line in the object frame, the camera frame and the image plane. All the parameters must be set in meter.
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
static double sqr(double x)
Class that defines the 3D point visual feature.
Class that defines a 2D line visual feature which is composed by two parameters that are and ...
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
unsigned int getRows() const
Class that defines what is a cylinder.
Implementation of column vector and the associated operations.
vpHomogeneousMatrix inverse() const
static vpHomogeneousMatrix direct(const vpColVector &v)
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
compute the interaction matrix from a subset a the possible features
Contains an M-Estimator and various influence function.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Class that defines 2D ellipse visual feature.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
void setThreshold(const double noise_threshold)
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
Class that defines what is a circle.
void setIteration(const unsigned int iter)
Set iteration.
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
void addFeatureLine(const vpLine &)
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
compute the interaction matrix from a subset a the possible features
void resize(const unsigned int i, const bool flagNullify=true)