41 #include <visp/vpPoseFeatures.h>
47 : maxSize(0), totalSize(0), vvsIterMax(200), lambda(1.0), verbose(false), computeCovariance(false),
48 covarianceMatrix(), featurePoint_Point_list(), featurePoint3D_Point_list(), featureVanishingPoint_Point_list(),
49 featureVanishingPoint_DuoLine_list(), featureEllipse_Sphere_list(), featureEllipse_Circle_list(),
50 featureLine_Line_list(), featureLine_DuoLineInt_List(), featureSegment_DuoPoints_list()
67 for(
int i = (
int)featurePoint_Point_list.size()-1 ; i >= 0 ; i--)
68 delete featurePoint_Point_list[(
unsigned int)i].desiredFeature;
69 featurePoint_Point_list.clear();
71 for(
int i = (
int)featurePoint3D_Point_list.size()-1 ; i >= 0 ; i--)
72 delete featurePoint3D_Point_list[(
unsigned int)i].desiredFeature;
73 featurePoint3D_Point_list.clear();
75 for(
int i = (
int)featureVanishingPoint_Point_list.size()-1 ; i >= 0 ; i--)
76 delete featureVanishingPoint_Point_list[(
unsigned int)i].desiredFeature;
77 featureVanishingPoint_Point_list.clear();
79 for(
int i = (
int)featureVanishingPoint_DuoLine_list.size()-1 ; i >= 0 ; i--)
80 delete featureVanishingPoint_DuoLine_list[(
unsigned int)i].desiredFeature;
81 featureVanishingPoint_DuoLine_list.clear();
83 for(
int i = (
int)featureEllipse_Sphere_list.size()-1 ; i >= 0 ; i--)
84 delete featureEllipse_Sphere_list[(
unsigned int)i].desiredFeature;
85 featureEllipse_Sphere_list.clear();
87 for(
int i = (
int)featureEllipse_Circle_list.size()-1 ; i >= 0 ; i--)
88 delete featureEllipse_Circle_list[(
unsigned int)i].desiredFeature;
89 featureEllipse_Circle_list.clear();
91 for(
int i = (
int)featureLine_Line_list.size()-1 ; i >= 0 ; i--)
92 delete featureLine_Line_list[(
unsigned int)i].desiredFeature;
93 featureLine_Line_list.clear();
95 for(
int i = (
int)featureLine_DuoLineInt_List.size()-1 ; i >= 0 ; i--)
96 delete featureLine_DuoLineInt_List[(
unsigned int)i].desiredFeature;
97 featureLine_DuoLineInt_List.clear();
99 for(
int i = (
int)featureSegment_DuoPoints_list.size()-1 ; i >= 0 ; i--)
100 delete featureSegment_DuoPoints_list[(
unsigned int)i].desiredFeature;
101 featureSegment_DuoPoints_list.clear();
103 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
104 for(
int i = (
int)featureSpecific_list.size()-1 ; i >= 0 ; i--)
105 delete featureSpecific_list[(
unsigned int)i];
106 featureSpecific_list.clear();
120 featurePoint_Point_list.push_back(vpDuo<vpFeaturePoint,vpPoint>());
121 featurePoint_Point_list.back().firstParam = p;
122 featurePoint_Point_list.back().desiredFeature =
new vpFeaturePoint();
126 if(featurePoint_Point_list.size() > maxSize)
127 maxSize = (
unsigned int)featurePoint_Point_list.size();
137 featurePoint3D_Point_list.push_back(vpDuo<vpFeaturePoint3D,vpPoint>());
138 featurePoint3D_Point_list.back().firstParam = p;
143 if(featurePoint3D_Point_list.size() > maxSize)
144 maxSize = (
unsigned int)featurePoint3D_Point_list.size();
154 featureVanishingPoint_Point_list.push_back(vpDuo<vpFeatureVanishingPoint,vpPoint>());
155 featureVanishingPoint_Point_list.back().firstParam = p;
160 if(featureVanishingPoint_Point_list.size() > maxSize)
161 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();
190 featureEllipse_Sphere_list.push_back(vpDuo<vpFeatureEllipse,vpSphere>());
191 featureEllipse_Sphere_list.back().firstParam = s;
196 if(featureEllipse_Sphere_list.size() > maxSize)
197 maxSize = (
unsigned int)featureEllipse_Sphere_list.size();
207 featureEllipse_Circle_list.push_back(vpDuo<vpFeatureEllipse,vpCircle>());
208 featureEllipse_Circle_list.back().firstParam = c;
213 if(featureEllipse_Circle_list.size() > maxSize)
214 maxSize = (
unsigned int)featureEllipse_Circle_list.size();
224 featureLine_Line_list.push_back(vpDuo<vpFeatureLine,vpLine>());
225 featureLine_Line_list.back().firstParam = l;
226 featureLine_Line_list.back().desiredFeature =
new vpFeatureLine();
230 if(featureLine_Line_list.size() > maxSize)
231 maxSize = (
unsigned int)featureLine_Line_list.size();
243 featureLine_DuoLineInt_List.push_back(vpTrio<vpFeatureLine,vpCylinder,int>());
244 featureLine_DuoLineInt_List.back().firstParam = c;
245 featureLine_DuoLineInt_List.back().secondParam = line;
246 featureLine_DuoLineInt_List.back().desiredFeature =
new vpFeatureLine();
250 if(featureLine_DuoLineInt_List.size() > maxSize)
251 maxSize = (
unsigned int)featureLine_DuoLineInt_List.size();
262 featureSegment_DuoPoints_list.push_back(vpTrio<vpFeatureSegment,vpPoint,vpPoint>());
263 featureSegment_DuoPoints_list.back().firstParam = P1;
264 featureSegment_DuoPoints_list.back().secondParam = P2;
265 featureSegment_DuoPoints_list.back().desiredFeature =
new vpFeatureSegment();
269 if(featureSegment_DuoPoints_list.size() > maxSize)
270 maxSize = (
unsigned int)featureSegment_DuoPoints_list.size();
285 for(
unsigned int i = 0 ; i < maxSize ; i++)
289 if( i < featurePoint_Point_list.size() ){
291 vpPoint p(featurePoint_Point_list[i].firstParam);
300 if( i < featurePoint3D_Point_list.size() ){
302 vpPoint p(featurePoint3D_Point_list[i].firstParam);
311 if( i < featureVanishingPoint_Point_list.size() ){
313 vpPoint p(featureVanishingPoint_Point_list[i].firstParam);
320 if( i < featureVanishingPoint_DuoLine_list.size() ){
322 vpLine l1(featureVanishingPoint_DuoLine_list[i].firstParam);
323 vpLine l2(featureVanishingPoint_DuoLine_list[i].secondParam);
327 err.
stackMatrices(fvp.
error(*(featureVanishingPoint_DuoLine_list[i].desiredFeature)));
333 if( i < featureEllipse_Sphere_list.size() ){
335 vpSphere s(featureEllipse_Sphere_list[i].firstParam);
342 if( i < featureEllipse_Circle_list.size() ){
344 vpCircle c(featureEllipse_Circle_list[i].firstParam);
353 if( i < featureLine_Line_list.size() ){
355 vpLine l(featureLine_Line_list[i].firstParam);
362 if( i < featureLine_DuoLineInt_List.size() ){
364 vpCylinder c(featureLine_DuoLineInt_List[i].firstParam);
373 if( i < featureSegment_DuoPoints_list.size() ){
375 vpPoint p1(featureSegment_DuoPoints_list[i].firstParam);
376 vpPoint p2(featureSegment_DuoPoints_list[i].secondParam);
384 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
386 if( i < featureSpecific_list.size() ){
387 featureSpecific_list[i]->createCurrent(cMo);
389 L.
stackMatrices(featureSpecific_list[i]->currentInteraction());
416 computePoseRobustVVS(cMo);
439 double residu_1 = 1e8 ;
447 unsigned int iter = 0;
449 while((
int)((residu_1 - r)*1e12) != 0 )
454 error_and_interaction(cMo,err,L);
465 vpTRACE(
"Rank must be at least 6 ! cMo not computed.");
474 if (iter++>vvsIterMax){
475 vpTRACE(
"Max iteration reached") ;
480 if(computeCovariance)
500 double residu_1 = 1e8 ;
510 robust.setThreshold(0.0000) ;
512 unsigned int iter = 0 ;
514 while((
int)((residu_1 - r)*1e12) !=0)
519 error_and_interaction(cMo,error,L);
531 for(
unsigned int k=0 ; k < error.
getRows()/2 ; k++)
535 robust.setIteration(0);
539 for (
unsigned int k=0 ; k < error.
getRows()/2 ; k++)
542 W[2*k+1][2*k+1] = w[k] ;
547 (W*L).pseudoInverse(Lp,1e-6) ;
552 vpTRACE(
"Rank must be at least 6 ! cMo not computed.");
558 v = -lambda*Lp*W*error ;
561 if (iter++>vvsIterMax){
562 vpTRACE(
"Max iteration reached") ;
567 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)
void stackMatrices(const vpMatrix &A)
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