50 #ifndef vpPoseFeatures_HH
51 #define vpPoseFeatures_HH
53 #include <visp/vpDebug.h>
54 #include <visp/vpException.h>
55 #include <visp/vpExponentialMap.h>
56 #include <visp/vpFeatureBuilder.h>
57 #include <visp/vpBasicFeature.h>
58 #include <visp/vpFeaturePoint.h>
59 #include <visp/vpFeatureEllipse.h>
60 #include <visp/vpRobust.h>
61 #include <visp/vpForwardProjection.h>
62 #include <visp/vpPoint.h>
63 #include <visp/vpCircle.h>
64 #include <visp/vpSphere.h>
65 #include <visp/vpLine.h>
66 #include <visp/vpCylinder.h>
71 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS
78 template <
unsigned int N >
79 struct vpDesiredFeatureBuilderWithTuple
81 template <
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args >
82 static void buildDesiredFeatureWithTuple( featureType &feature,
83 RetType (*f)( ArgsF... ),
84 const std::tuple<ArgsT...>& t,
87 vpDesiredFeatureBuilderWithTuple<N-1>::buildDesiredFeatureWithTuple( feature, f, t, std::get<N-1>( t ), args... );
92 struct vpDesiredFeatureBuilderWithTuple<0>
94 template <
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args >
95 static void buildDesiredFeatureWithTuple( featureType &,
96 RetType (*f)( ArgsF... ),
97 const std::tuple<ArgsT...>& ,
105 struct vpDesiredFeatureBuilderWithTuple<1>
107 template <
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args >
108 static void buildDesiredFeatureWithTuple( featureType &feature,
109 RetType (*f)( ArgsF... ),
110 const std::tuple<ArgsT...>& t,
113 vpDesiredFeatureBuilderWithTuple<0>::buildDesiredFeatureWithTuple( feature, f, t, feature, args... );
117 template <
typename featureType,
typename RetType,
typename... Args,
typename... ArgsFunc >
118 void buildDesiredFeatureWithTuple( featureType &feature,
119 RetType (*f)(ArgsFunc...),
120 std::tuple<Args...>
const& t )
122 vpDesiredFeatureBuilderWithTuple<
sizeof...(Args)>::buildDesiredFeatureWithTuple( feature, f, t );
130 template <
unsigned int N >
131 struct vpDesiredFeatureBuilderObjectWithTuple
133 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args >
134 static void buildDesiredFeatureObjectWithTuple( objType *obj, featureType &feature,
135 RetType (objType::*f)( ArgsF... ),
136 const std::tuple<ArgsT...>& t,
139 vpDesiredFeatureBuilderObjectWithTuple<N-1>::buildDesiredFeatureObjectWithTuple( obj, feature, f, t, std::get<N-1>( t ), args... );
144 struct vpDesiredFeatureBuilderObjectWithTuple<0>
146 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args >
147 static void buildDesiredFeatureObjectWithTuple( objType *obj, featureType & ,
148 RetType (objType::*f)( ArgsF... ),
149 const std::tuple<ArgsT...>& ,
152 (obj->*f)( args... );
157 struct vpDesiredFeatureBuilderObjectWithTuple<1>
159 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args >
160 static void buildDesiredFeatureObjectWithTuple( objType *obj, featureType &feature,
161 RetType (objType::*f)( ArgsF... ),
162 const std::tuple<ArgsT...>& t,
165 vpDesiredFeatureBuilderObjectWithTuple<0>::buildDesiredFeatureObjectWithTuple( obj, feature, f, t, feature, args... );
169 template <
typename objType,
typename featureType,
typename RetType,
typename... Args,
typename... ArgsFunc >
170 void buildDesiredFeatureObjectWithTuple( objType *obj, featureType &feature,
171 RetType (objType::*f)(ArgsFunc...),
172 std::tuple<Args...>
const& t )
174 vpDesiredFeatureBuilderObjectWithTuple<
sizeof...(Args)>::buildDesiredFeatureObjectWithTuple( obj, feature, f, t );
183 template <
unsigned int N >
184 struct vpCurrentFeatureBuilderWithTuple
186 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
typename... ArgsF >
187 static void buildCurrentFeatureWithTuple( featureType &feature,
189 RetType (*f)(ArgsF...), std::tuple<ArgsTuple...>& t,
190 ArgsDecomposed &&... args )
192 auto proj = std::get<N-1>( t );
194 vpCurrentFeatureBuilderWithTuple<N-1>::buildCurrentFeatureWithTuple( feature, cMo, f, t, proj, args... );
199 struct vpCurrentFeatureBuilderWithTuple<0>
201 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
typename... ArgsF >
202 static void buildCurrentFeatureWithTuple( featureType &,
204 RetType (*f)(ArgsF...),
205 std::tuple<ArgsTuple...>&,
206 ArgsDecomposed &&... args )
213 struct vpCurrentFeatureBuilderWithTuple<1>
215 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
typename... ArgsF >
216 static void buildCurrentFeatureWithTuple( featureType &feature,
218 RetType (*f)(ArgsF...),
219 std::tuple<ArgsTuple...>&t,
220 ArgsDecomposed &&... args )
222 vpCurrentFeatureBuilderWithTuple<0>::buildCurrentFeatureWithTuple( feature, cMo, f, t, feature, args... );
226 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsFunc >
227 void buildCurrentFeatureWithTuple( featureType &feature,
229 RetType (*f)(ArgsFunc...),
230 std::tuple<ArgsTuple...> &t )
232 vpCurrentFeatureBuilderWithTuple<
sizeof...(ArgsTuple)>::buildCurrentFeatureWithTuple( feature, cMo, f, t );
242 template <
unsigned int N >
243 struct vpCurrentFeatureBuilderObjectWithTuple
245 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
typename... ArgsF >
246 static void buildCurrentFeatureObjectWithTuple( objType *obj, featureType &feature,
248 RetType (objType::*f)(ArgsF...),
249 std::tuple<ArgsTuple...>& t,
250 ArgsDecomposed &&... args )
252 auto proj = std::get<N-1>( t );
254 vpCurrentFeatureBuilderObjectWithTuple<N-1>::buildCurrentFeatureObjectWithTuple( obj, feature, cMo, f, t, proj, args... );
259 struct vpCurrentFeatureBuilderObjectWithTuple<0>
261 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
typename... ArgsF >
262 static void buildCurrentFeatureObjectWithTuple( objType *obj, featureType &,
264 RetType (objType::*f)(ArgsF...),
265 std::tuple<ArgsTuple...>&,
266 ArgsDecomposed &&... args )
268 (obj->*f)( args... );
273 struct vpCurrentFeatureBuilderObjectWithTuple<1>
275 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
typename... ArgsF >
276 static void buildCurrentFeatureObjectWithTuple( objType *obj, featureType &feature,
278 RetType (objType::*f)(ArgsF...),
279 std::tuple<ArgsTuple...>&t,
280 ArgsDecomposed &&... args )
282 vpCurrentFeatureBuilderObjectWithTuple<0>::buildCurrentFeatureObjectWithTuple( obj, feature, cMo, f, t, feature, args... );
286 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsFunc >
287 void buildCurrentFeatureObjectWithTuple( objType *obj, featureType &feature,
289 RetType (objType::*f)(ArgsFunc...),
290 std::tuple<ArgsTuple...> &t )
292 vpCurrentFeatureBuilderObjectWithTuple<
sizeof...(ArgsTuple)>::buildCurrentFeatureObjectWithTuple( obj, feature, cMo, f, t );
304 class VISP_EXPORT vpPoseSpecificFeature
307 vpPoseSpecificFeature(){}
308 virtual ~vpPoseSpecificFeature(){};
311 virtual vpMatrix currentInteraction() = 0;
312 virtual void createDesired() = 0;
325 template<
typename featureType,
typename RetType,
typename ...Args >
326 class vpPoseSpecificFeatureTemplate :
public vpPoseSpecificFeature
329 featureType desiredFeature;
330 featureType currentFeature;
331 std::tuple<Args...> *tuple;
332 RetType (*func_ptr)(Args...);
335 vpPoseSpecificFeatureTemplate(RetType (*f_ptr)(Args...), Args &&...args)
338 tuple =
new std::tuple<Args...>(args...);
341 virtual ~vpPoseSpecificFeatureTemplate()
346 virtual void createDesired(){
347 buildDesiredFeatureWithTuple(desiredFeature, func_ptr, *tuple);
352 return currentFeature.error(desiredFeature);
355 virtual vpMatrix currentInteraction(){
356 return currentFeature.interaction();
360 buildCurrentFeatureWithTuple(currentFeature, cMo, func_ptr, *tuple);
374 template<
typename ObjectType,
typename featureType,
typename RetType,
typename ...Args >
375 class vpPoseSpecificFeatureTemplateObject :
public vpPoseSpecificFeature
378 featureType desiredFeature;
379 featureType currentFeature;
380 std::tuple<Args...> *tuple;
381 RetType (ObjectType::*func_ptr)(Args...);
385 vpPoseSpecificFeatureTemplateObject(ObjectType *o, RetType (ObjectType::*f_ptr)(Args...), Args &&...args)
388 tuple =
new std::tuple<Args...>(args...);
392 virtual ~vpPoseSpecificFeatureTemplateObject()
397 virtual void createDesired(){
398 buildDesiredFeatureObjectWithTuple(obj, desiredFeature, func_ptr, *tuple);
402 return currentFeature.error(desiredFeature);
405 virtual vpMatrix currentInteraction(){
406 return currentFeature.interaction();
410 buildCurrentFeatureObjectWithTuple(obj, currentFeature, cMo, func_ptr, *tuple);
413 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
414 #endif //VISP_HAVE_CPP11_COMPATIBILITY
434 } vpPoseFeaturesMethodType;
438 #ifndef DOXYGEN_SHOULD_SKIP_THIS
439 template<
typename FeatureType,
typename FirstParamType>
441 FeatureType *desiredFeature;
442 FirstParamType firstParam;
443 vpDuo() : desiredFeature(NULL), firstParam() {}
446 template<
typename FeatureType,
typename FirstParamType,
typename SecondParamType>
448 FeatureType *desiredFeature;
449 FirstParamType firstParam;
450 SecondParamType secondParam;
452 vpTrio() : desiredFeature(NULL), firstParam(), secondParam() {}
454 #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS
456 unsigned int maxSize;
457 unsigned int totalSize;
458 unsigned int vvsIterMax;
463 bool computeCovariance;
467 std::vector<vpDuo<vpFeaturePoint,vpPoint> > featurePoint_Point_list;
469 std::vector<vpDuo<vpFeaturePoint3D,vpPoint> > featurePoint3D_Point_list;
471 std::vector<vpDuo<vpFeatureVanishingPoint,vpPoint> > featureVanishingPoint_Point_list;
472 std::vector<vpTrio<vpFeatureVanishingPoint,vpLine,vpLine> > featureVanishingPoint_DuoLine_list;
474 std::vector<vpDuo<vpFeatureEllipse,vpSphere> > featureEllipse_Sphere_list;
475 std::vector<vpDuo<vpFeatureEllipse,vpCircle> > featureEllipse_Circle_list;
477 std::vector<vpDuo<vpFeatureLine,vpLine> > featureLine_Line_list;
478 std::vector<vpTrio<vpFeatureLine,vpCylinder,int> > featureLine_DuoLineInt_List;
480 std::vector<vpTrio<vpFeatureSegment,vpPoint,vpPoint> > featureSegment_DuoPoints_list;
482 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
484 std::vector<vpPoseSpecificFeature*> featureSpecific_list;
493 void addFeaturePoint(
const vpPoint&);
495 void addFeaturePoint3D(
const vpPoint&);
497 void addFeatureVanishingPoint(
const vpPoint&);
498 void addFeatureVanishingPoint(
const vpLine&,
const vpLine&);
500 void addFeatureEllipse(
const vpCircle&);
501 void addFeatureEllipse(
const vpSphere&);
503 void addFeatureLine(
const vpLine&);
504 void addFeatureLine(
const vpCylinder&,
const int &line);
509 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
510 template<
typename RetType,
typename ...ArgsFunc,
typename ...Args>
511 void addSpecificFeature(RetType (*fct_ptr)(ArgsFunc ...), Args &&...args);
513 template<
typename ObjType,
typename RetType,
typename ...ArgsFunc,
typename ...Args>
514 void addSpecificFeature(ObjType *obj, RetType (ObjType::*fct_ptr)(ArgsFunc ...), Args &&...args);
520 void computePose(
vpHomogeneousMatrix & cMo,
const vpPoseFeaturesMethodType &type = VIRTUAL_VS);
528 if(!computeCovariance)
529 vpTRACE(
"Warning : The covariance matrix has not been computed. See setCovarianceComputation() to do it.");
531 return covarianceMatrix;
584 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
638 template<
typename RetType,
typename ...ArgsFunc,
typename ...Args>
641 typedef typename std::tuple_element<0, std::tuple<Args...> >::type featureTypeReference;
642 typedef typename std::remove_reference<featureTypeReference>::type featureType;
643 featureSpecific_list.push_back(
644 new vpPoseSpecificFeatureTemplate< featureType, RetType, ArgsFunc... >(fct_ptr,std::forward<ArgsFunc>(args)...)
647 featureSpecific_list.back()->createDesired();
650 if(featureSpecific_list.size() > maxSize)
651 maxSize = featureSpecific_list.size();
717 template<
typename ObjType,
typename RetType,
typename ...ArgsFunc,
typename ...Args>
720 typedef typename std::tuple_element<0, std::tuple<Args...> >::type featureTypeReference;
721 typedef typename std::remove_reference<featureTypeReference>::type featureType;
722 featureSpecific_list.push_back(
723 new vpPoseSpecificFeatureTemplateObject< ObjType, featureType, RetType, ArgsFunc... >(obj, fct_ptr,std::forward<ArgsFunc>(args)...)
726 featureSpecific_list.back()->createDesired();
729 if(featureSpecific_list.size() > maxSize)
730 maxSize = featureSpecific_list.size();
Definition of the vpMatrix class.
void setVerbose(const bool &mode)
void setVVSIterMax(const unsigned int &val)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void setLambda(const double &val)
Class that defines what is a sphere.
Class that defines what is a point.
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 what is a cylinder.
void setCovarianceComputation(const bool &flag)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpMatrix getCovarianceMatrix() const
void addSpecificFeature(RetType(*fct_ptr)(ArgsFunc...), Args &&...args)
unsigned int getVVSIterMax()
Tools for pose computation from any feature.This class allows to estimate a pose by virtual visual se...
Class that defines what is a circle.