41 #include <visp/vpPoseFeatures.h>
69 for(
int i = (
int)featurePoint_Point_list.size()-1 ; i >= 0 ; i--)
70 delete featurePoint_Point_list[(
unsigned int)i].desiredFeature;
71 featurePoint_Point_list.clear();
73 for(
int i = (
int)featurePoint3D_Point_list.size()-1 ; i >= 0 ; i--)
74 delete featurePoint3D_Point_list[(
unsigned int)i].desiredFeature;
75 featurePoint3D_Point_list.clear();
77 for(
int i = (
int)featureVanishingPoint_Point_list.size()-1 ; i >= 0 ; i--)
78 delete featureVanishingPoint_Point_list[(
unsigned int)i].desiredFeature;
79 featureVanishingPoint_Point_list.clear();
81 for(
int i = (
int)featureVanishingPoint_DuoLine_list.size()-1 ; i >= 0 ; i--)
82 delete featureVanishingPoint_DuoLine_list[(
unsigned int)i].desiredFeature;
83 featureVanishingPoint_DuoLine_list.clear();
85 for(
int i = (
int)featureEllipse_Sphere_list.size()-1 ; i >= 0 ; i--)
86 delete featureEllipse_Sphere_list[(
unsigned int)i].desiredFeature;
87 featureEllipse_Sphere_list.clear();
89 for(
int i = (
int)featureEllipse_Circle_list.size()-1 ; i >= 0 ; i--)
90 delete featureEllipse_Circle_list[(
unsigned int)i].desiredFeature;
91 featureEllipse_Circle_list.clear();
93 for(
int i = (
int)featureLine_Line_list.size()-1 ; i >= 0 ; i--)
94 delete featureLine_Line_list[(
unsigned int)i].desiredFeature;
95 featureLine_Line_list.clear();
97 for(
int i = (
int)featureLine_DuoLineInt_List.size()-1 ; i >= 0 ; i--)
98 delete featureLine_DuoLineInt_List[(
unsigned int)i].desiredFeature;
99 featureLine_DuoLineInt_List.clear();
101 for(
int i = (
int)featureSegment_DuoPoints_list.size()-1 ; i >= 0 ; i--)
102 delete featureSegment_DuoPoints_list[(
unsigned int)i].desiredFeature;
103 featureSegment_DuoPoints_list.clear();
105 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
106 for(
int i = (
int)featureSpecific_list.size()-1 ; i >= 0 ; i--)
107 delete featureSpecific_list[(
unsigned int)i];
108 featureSpecific_list.clear();
122 featurePoint_Point_list.push_back(vpDuo<vpFeaturePoint,vpPoint>());
123 featurePoint_Point_list.back().firstParam = p;
124 featurePoint_Point_list.back().desiredFeature =
new vpFeaturePoint();
128 if(featurePoint_Point_list.size() > maxSize)
129 maxSize = (
unsigned int)featurePoint_Point_list.size();
139 featurePoint3D_Point_list.push_back(vpDuo<vpFeaturePoint3D,vpPoint>());
140 featurePoint3D_Point_list.back().firstParam = p;
145 if(featurePoint3D_Point_list.size() > maxSize)
146 maxSize = (
unsigned int)featurePoint3D_Point_list.size();
156 featureVanishingPoint_Point_list.push_back(vpDuo<vpFeatureVanishingPoint,vpPoint>());
157 featureVanishingPoint_Point_list.back().firstParam = p;
162 if(featureVanishingPoint_Point_list.size() > maxSize)
163 maxSize = (
unsigned int)featureVanishingPoint_Point_list.size();
174 featureVanishingPoint_DuoLine_list.push_back(vpTrio<vpFeatureVanishingPoint,vpLine,vpLine>());
175 featureVanishingPoint_DuoLine_list.back().firstParam = l1;
176 featureVanishingPoint_DuoLine_list.back().secondParam = l2;
181 if(featureVanishingPoint_DuoLine_list.size() > maxSize)
182 maxSize = (
unsigned int)featureVanishingPoint_DuoLine_list.size();
192 featureEllipse_Sphere_list.push_back(vpDuo<vpFeatureEllipse,vpSphere>());
193 featureEllipse_Sphere_list.back().firstParam = s;
198 if(featureEllipse_Sphere_list.size() > maxSize)
199 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();
226 featureLine_Line_list.push_back(vpDuo<vpFeatureLine,vpLine>());
227 featureLine_Line_list.back().firstParam = l;
228 featureLine_Line_list.back().desiredFeature =
new vpFeatureLine();
232 if(featureLine_Line_list.size() > maxSize)
233 maxSize = (
unsigned int)featureLine_Line_list.size();
245 featureLine_DuoLineInt_List.push_back(vpTrio<vpFeatureLine,vpCylinder,int>());
246 featureLine_DuoLineInt_List.back().firstParam = c;
247 featureLine_DuoLineInt_List.back().secondParam = line;
248 featureLine_DuoLineInt_List.back().desiredFeature =
new vpFeatureLine();
252 if(featureLine_DuoLineInt_List.size() > maxSize)
253 maxSize = (
unsigned int)featureLine_DuoLineInt_List.size();
264 featureSegment_DuoPoints_list.push_back(vpTrio<vpFeatureSegment,vpPoint,vpPoint>());
265 featureSegment_DuoPoints_list.back().firstParam = P1;
266 featureSegment_DuoPoints_list.back().secondParam = P2;
267 featureSegment_DuoPoints_list.back().desiredFeature =
new vpFeatureSegment();
271 if(featureSegment_DuoPoints_list.size() > maxSize)
272 maxSize = (
unsigned int)featureSegment_DuoPoints_list.size();
287 for(
unsigned int i = 0 ; i < maxSize ; i++)
291 if( i < featurePoint_Point_list.size() ){
293 vpPoint p(featurePoint_Point_list[i].firstParam);
302 if( i < featurePoint3D_Point_list.size() ){
304 vpPoint p(featurePoint3D_Point_list[i].firstParam);
313 if( i < featureVanishingPoint_Point_list.size() ){
315 vpPoint p(featureVanishingPoint_Point_list[i].firstParam);
322 if( i < featureVanishingPoint_DuoLine_list.size() ){
324 vpLine l1(featureVanishingPoint_DuoLine_list[i].firstParam);
325 vpLine l2(featureVanishingPoint_DuoLine_list[i].secondParam);
329 err.
stackMatrices(fvp.
error(*(featureVanishingPoint_DuoLine_list[i].desiredFeature)));
335 if( i < featureEllipse_Sphere_list.size() ){
337 vpSphere s(featureEllipse_Sphere_list[i].firstParam);
344 if( i < featureEllipse_Circle_list.size() ){
346 vpCircle c(featureEllipse_Circle_list[i].firstParam);
355 if( i < featureLine_Line_list.size() ){
357 vpLine l(featureLine_Line_list[i].firstParam);
364 if( i < featureLine_DuoLineInt_List.size() ){
366 vpCylinder c(featureLine_DuoLineInt_List[i].firstParam);
375 if( i < featureSegment_DuoPoints_list.size() ){
377 vpPoint p1(featureSegment_DuoPoints_list[i].firstParam);
378 vpPoint p2(featureSegment_DuoPoints_list[i].secondParam);
386 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
388 if( i < featureSpecific_list.size() ){
389 featureSpecific_list[i]->createCurrent(cMo);
391 L.
stackMatrices(featureSpecific_list[i]->currentInteraction());
418 computePoseRobustVVS(cMo);
441 double residu_1 = 1e8 ;
449 unsigned int iter = 0;
451 while((
int)((residu_1 - r)*1e12) != 0 )
456 error_and_interaction(cMo,err,L);
467 vpTRACE(
"Rank must be at least 6 ! cMo not computed.");
476 if (iter++>vvsIterMax){
477 vpTRACE(
"Max iteration reached") ;
482 if(computeCovariance)
502 double residu_1 = 1e8 ;
512 robust.setThreshold(0.0000) ;
514 unsigned int iter = 0 ;
516 while((
int)((residu_1 - r)*1e12) !=0)
521 error_and_interaction(cMo,error,L);
533 for(
unsigned int k=0 ; k < error.
getRows()/2 ; k++)
537 robust.setIteration(0);
541 for (
unsigned int k=0 ; k < error.
getRows()/2 ; k++)
544 W[2*k+1][2*k+1] = w[k] ;
549 (W*L).pseudoInverse(Lp,1e-6) ;
554 vpTRACE(
"Rank must be at least 6 ! cMo not computed.");
560 v = -lambda*Lp*W*error ;
563 if (iter++>vvsIterMax){
564 vpTRACE(
"Max iteration reached") ;
569 if(computeCovariance)
Definition of the vpMatrix class.
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)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
Class that defines 2D vanishing point visual feature (Z coordinate in 3D space is infinity)...
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)
double sumSquare() const
return sum of the Aij^2 (for all i, for all j)
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)
static vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B)
Stack two Matrices C = [ A B ]^T.
Class that defines what is a cylinder.
Class that provides a data structure for the column vectors as well as a set of operations on these v...
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
Compute the pseudo inverse of the matrix using the SVD.
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)
unsigned int getRows() const
Return the number of rows of the matrix.
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
Class that defines what is a circle.
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