47 #ifndef vpPoseFeatures_HH 48 #define vpPoseFeatures_HH 50 #include <visp3/core/vpConfig.h> 52 #ifdef VISP_HAVE_MODULE_VISUAL_FEATURES 54 #include <visp3/core/vpCircle.h> 55 #include <visp3/core/vpCylinder.h> 56 #include <visp3/core/vpDebug.h> 57 #include <visp3/core/vpException.h> 58 #include <visp3/core/vpExponentialMap.h> 59 #include <visp3/core/vpForwardProjection.h> 60 #include <visp3/core/vpLine.h> 61 #include <visp3/core/vpPoint.h> 62 #include <visp3/core/vpRobust.h> 63 #include <visp3/core/vpSphere.h> 64 #include <visp3/visual_features/vpBasicFeature.h> 65 #include <visp3/visual_features/vpFeatureBuilder.h> 66 #include <visp3/visual_features/vpFeatureEllipse.h> 67 #include <visp3/visual_features/vpFeaturePoint.h> 72 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 75 #ifndef DOXYGEN_SHOULD_SKIP_THIS 79 template <
unsigned int N>
struct vpDesiredFeatureBuilderWithTuple {
80 template <
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args>
81 static void buildDesiredFeatureWithTuple(featureType &feature, RetType (*f)(ArgsF...),
const std::tuple<ArgsT...> &t,
84 vpDesiredFeatureBuilderWithTuple<N - 1>::buildDesiredFeatureWithTuple(feature, f, t, std::get<N - 1>(t), args...);
88 template <>
struct vpDesiredFeatureBuilderWithTuple<0> {
89 template <
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args>
90 static void buildDesiredFeatureWithTuple(featureType & , RetType (*f)(ArgsF...),
91 const std::tuple<ArgsT...> & , Args &&... args)
97 template <>
struct vpDesiredFeatureBuilderWithTuple<1> {
98 template <
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
typename... Args>
99 static void buildDesiredFeatureWithTuple(featureType &feature, RetType (*f)(ArgsF...),
const std::tuple<ArgsT...> &t,
102 vpDesiredFeatureBuilderWithTuple<0>::buildDesiredFeatureWithTuple(feature, f, t, feature, args...);
106 template <
typename featureType,
typename RetType,
typename... Args,
typename... ArgsFunc>
107 void buildDesiredFeatureWithTuple(featureType &feature, RetType (*f)(ArgsFunc...), std::tuple<Args...>
const &t)
109 vpDesiredFeatureBuilderWithTuple<
sizeof...(Args)>::buildDesiredFeatureWithTuple(feature, f, t);
117 template <
unsigned int N>
struct vpDesiredFeatureBuilderObjectWithTuple {
118 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
120 static void buildDesiredFeatureObjectWithTuple(objType *obj, featureType &feature, RetType (objType::*f)(ArgsF...),
121 const std::tuple<ArgsT...> &t, Args &&... args)
123 vpDesiredFeatureBuilderObjectWithTuple<N - 1>::buildDesiredFeatureObjectWithTuple(obj, feature, f, t,
124 std::get<N - 1>(t), args...);
128 template <>
struct vpDesiredFeatureBuilderObjectWithTuple<0> {
129 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
131 static void buildDesiredFeatureObjectWithTuple(objType *obj, featureType & ,
132 RetType (objType::*f)(ArgsF...),
const std::tuple<ArgsT...> & ,
139 template <>
struct vpDesiredFeatureBuilderObjectWithTuple<1> {
140 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsF,
typename... ArgsT,
142 static void buildDesiredFeatureObjectWithTuple(objType *obj, featureType &feature, RetType (objType::*f)(ArgsF...),
143 const std::tuple<ArgsT...> &t, Args &&... args)
145 vpDesiredFeatureBuilderObjectWithTuple<0>::buildDesiredFeatureObjectWithTuple(obj, feature, f, t, feature, args...);
149 template <
typename objType,
typename featureType,
typename RetType,
typename... Args,
typename... ArgsFunc>
150 void buildDesiredFeatureObjectWithTuple(objType *obj, featureType &feature, RetType (objType::*f)(ArgsFunc...),
151 std::tuple<Args...>
const &t)
153 vpDesiredFeatureBuilderObjectWithTuple<
sizeof...(Args)>::buildDesiredFeatureObjectWithTuple(obj, feature, f, t);
162 template <
unsigned int N>
struct vpCurrentFeatureBuilderWithTuple {
163 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
165 static void buildCurrentFeatureWithTuple(featureType &feature,
const vpHomogeneousMatrix &cMo, RetType (*f)(ArgsF...),
166 std::tuple<ArgsTuple...> &t, ArgsDecomposed &&... args)
168 auto proj = std::get<N - 1>(t);
170 vpCurrentFeatureBuilderWithTuple<N - 1>::buildCurrentFeatureWithTuple(feature, cMo, f, t, proj, args...);
174 template <>
struct vpCurrentFeatureBuilderWithTuple<0> {
175 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
178 RetType (*f)(ArgsF...), std::tuple<ArgsTuple...> &,
179 ArgsDecomposed &&... args)
185 template <>
struct vpCurrentFeatureBuilderWithTuple<1> {
186 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
188 static void buildCurrentFeatureWithTuple(featureType &feature,
const vpHomogeneousMatrix &cMo, RetType (*f)(ArgsF...),
189 std::tuple<ArgsTuple...> &t, ArgsDecomposed &&... args)
191 vpCurrentFeatureBuilderWithTuple<0>::buildCurrentFeatureWithTuple(feature, cMo, f, t, feature, args...);
195 template <
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsFunc>
196 void buildCurrentFeatureWithTuple(featureType &feature,
const vpHomogeneousMatrix &cMo, RetType (*f)(ArgsFunc...),
197 std::tuple<ArgsTuple...> &t)
199 vpCurrentFeatureBuilderWithTuple<
sizeof...(ArgsTuple)>::buildCurrentFeatureWithTuple(feature, cMo, f, t);
209 template <
unsigned int N>
struct vpCurrentFeatureBuilderObjectWithTuple {
210 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
212 static void buildCurrentFeatureObjectWithTuple(objType *obj, featureType &feature,
const vpHomogeneousMatrix &cMo,
213 RetType (objType::*f)(ArgsF...), std::tuple<ArgsTuple...> &t,
214 ArgsDecomposed &&... args)
216 auto proj = std::get<N - 1>(t);
218 vpCurrentFeatureBuilderObjectWithTuple<N - 1>::buildCurrentFeatureObjectWithTuple(obj, feature, cMo, f, t, proj,
223 template <>
struct vpCurrentFeatureBuilderObjectWithTuple<0> {
224 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
226 static void buildCurrentFeatureObjectWithTuple(objType *obj, featureType & ,
228 std::tuple<ArgsTuple...> &, ArgsDecomposed &&... args)
234 template <>
struct vpCurrentFeatureBuilderObjectWithTuple<1> {
235 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsDecomposed,
237 static void buildCurrentFeatureObjectWithTuple(objType *obj, featureType &feature,
const vpHomogeneousMatrix &cMo,
238 RetType (objType::*f)(ArgsF...), std::tuple<ArgsTuple...> &t,
239 ArgsDecomposed &&... args)
241 vpCurrentFeatureBuilderObjectWithTuple<0>::buildCurrentFeatureObjectWithTuple(obj, feature, cMo, f, t, feature,
246 template <
typename objType,
typename featureType,
typename RetType,
typename... ArgsTuple,
typename... ArgsFunc>
247 void buildCurrentFeatureObjectWithTuple(objType *obj, featureType &feature,
const vpHomogeneousMatrix &cMo,
248 RetType (objType::*f)(ArgsFunc...), std::tuple<ArgsTuple...> &t)
250 vpCurrentFeatureBuilderObjectWithTuple<
sizeof...(ArgsTuple)>::buildCurrentFeatureObjectWithTuple(obj, feature, cMo, f,
264 class VISP_EXPORT vpPoseSpecificFeature
267 vpPoseSpecificFeature() {}
268 virtual ~vpPoseSpecificFeature(){};
271 virtual vpMatrix currentInteraction() = 0;
272 virtual void createDesired() = 0;
286 template <
typename featureType,
typename RetType,
typename... Args>
287 class vpPoseSpecificFeatureTemplate :
public vpPoseSpecificFeature
290 featureType desiredFeature;
291 featureType currentFeature;
292 std::tuple<Args...> *tuple;
293 RetType (*func_ptr)(Args...);
296 vpPoseSpecificFeatureTemplate(RetType (*f_ptr)(Args...), Args &&... args)
299 tuple =
new std::tuple<Args...>(args...);
302 virtual ~vpPoseSpecificFeatureTemplate() {
delete tuple; };
304 virtual void createDesired() { buildDesiredFeatureWithTuple(desiredFeature, func_ptr, *tuple); }
310 return currentFeature.error(desiredFeature);
313 virtual vpMatrix currentInteraction() {
return currentFeature.interaction(); }
317 buildCurrentFeatureWithTuple(currentFeature, cMo, func_ptr, *tuple);
332 template <
typename ObjectType,
typename featureType,
typename RetType,
typename... Args>
333 class vpPoseSpecificFeatureTemplateObject :
public vpPoseSpecificFeature
336 featureType desiredFeature;
337 featureType currentFeature;
338 std::tuple<Args...> *tuple;
339 RetType (ObjectType::*func_ptr)(Args...);
343 vpPoseSpecificFeatureTemplateObject(ObjectType *o, RetType (ObjectType::*f_ptr)(Args...), Args &&... args)
346 tuple =
new std::tuple<Args...>(args...);
350 virtual ~vpPoseSpecificFeatureTemplateObject() {
delete tuple; };
352 virtual void createDesired() { buildDesiredFeatureObjectWithTuple(obj, desiredFeature, func_ptr, *tuple); }
354 virtual vpColVector error() {
return currentFeature.error(desiredFeature); }
356 virtual vpMatrix currentInteraction() {
return currentFeature.interaction(); }
360 buildCurrentFeatureObjectWithTuple(obj, currentFeature, cMo, func_ptr, *tuple);
363 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 364 #endif // VISP_HAVE_CPP11_COMPATIBILITY 388 #ifndef DOXYGEN_SHOULD_SKIP_THIS 389 template <
typename FeatureType,
typename FirstParamType>
struct vpDuo {
390 FeatureType *desiredFeature;
391 FirstParamType firstParam;
392 vpDuo() : desiredFeature(NULL), firstParam() {}
395 template <
typename FeatureType,
typename FirstParamType,
typename SecondParamType>
struct vpTrio {
396 FeatureType *desiredFeature;
397 FirstParamType firstParam;
398 SecondParamType secondParam;
400 vpTrio() : desiredFeature(NULL), firstParam(), secondParam() {}
402 #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS 404 unsigned int maxSize;
405 unsigned int totalSize;
406 unsigned int vvsIterMax;
411 bool computeCovariance;
415 std::vector<vpDuo<vpFeaturePoint, vpPoint> > featurePoint_Point_list;
417 std::vector<vpDuo<vpFeaturePoint3D, vpPoint> > featurePoint3D_Point_list;
419 std::vector<vpDuo<vpFeatureVanishingPoint, vpPoint> > featureVanishingPoint_Point_list;
420 std::vector<vpTrio<vpFeatureVanishingPoint, vpLine, vpLine> > featureVanishingPoint_DuoLine_list;
422 std::vector<vpDuo<vpFeatureEllipse, vpSphere> > featureEllipse_Sphere_list;
423 std::vector<vpDuo<vpFeatureEllipse, vpCircle> > featureEllipse_Circle_list;
425 std::vector<vpDuo<vpFeatureLine, vpLine> > featureLine_Line_list;
426 std::vector<vpTrio<vpFeatureLine, vpCylinder, int> > featureLine_DuoLineInt_List;
428 std::vector<vpTrio<vpFeatureSegment, vpPoint, vpPoint> > featureSegment_DuoPoints_list;
430 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 432 std::vector<vpPoseSpecificFeature *> featureSpecific_list;
440 void addFeaturePoint(
const vpPoint &);
442 void addFeaturePoint3D(
const vpPoint &);
444 void addFeatureVanishingPoint(
const vpPoint &);
445 void addFeatureVanishingPoint(
const vpLine &,
const vpLine &);
447 void addFeatureEllipse(
const vpCircle &);
448 void addFeatureEllipse(
const vpSphere &);
450 void addFeatureLine(
const vpLine &);
451 void addFeatureLine(
const vpCylinder &,
const int &line);
455 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 456 template <
typename RetType,
typename... ArgsFunc,
typename... Args>
457 void addSpecificFeature(RetType (*fct_ptr)(ArgsFunc...), Args &&... args);
459 template <
typename ObjType,
typename RetType,
typename... ArgsFunc,
typename... Args>
460 void addSpecificFeature(ObjType *obj, RetType (ObjType::*fct_ptr)(ArgsFunc...), Args &&... args);
466 void computePose(
vpHomogeneousMatrix &cMo,
const vpPoseFeaturesMethodType &type = VIRTUAL_VS);
477 if (!computeCovariance)
478 vpTRACE(
"Warning : The covariance matrix has not been computed. See " 479 "setCovarianceComputation() to do it.");
481 return covarianceMatrix;
536 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 592 template <
typename RetType,
typename... ArgsFunc,
typename... Args>
595 typedef typename std::tuple_element<0, std::tuple<Args...> >::type featureTypeReference;
596 typedef typename std::remove_reference<featureTypeReference>::type featureType;
597 featureSpecific_list.push_back(
598 new vpPoseSpecificFeatureTemplate<featureType, RetType, ArgsFunc...>(fct_ptr, std::forward<ArgsFunc>(args)...));
600 featureSpecific_list.back()->createDesired();
603 if (featureSpecific_list.size() > maxSize)
604 maxSize = (
unsigned int)featureSpecific_list.size();
674 template <
typename ObjType,
typename RetType,
typename... ArgsFunc,
typename... Args>
677 typedef typename std::tuple_element<0, std::tuple<Args...> >::type featureTypeReference;
678 typedef typename std::remove_reference<featureTypeReference>::type featureType;
679 featureSpecific_list.push_back(
new vpPoseSpecificFeatureTemplateObject<ObjType, featureType, RetType, ArgsFunc...>(
680 obj, fct_ptr, std::forward<ArgsFunc>(args)...));
682 featureSpecific_list.back()->createDesired();
685 if (featureSpecific_list.size() > maxSize)
686 maxSize = (
unsigned int)featureSpecific_list.size();
690 #endif //#ifdef VISP_HAVE_MODULE_VISUAL_FEATURES Implementation of a matrix and operations on matrices.
void setVerbose(const bool &mode)
void setVVSIterMax(const unsigned int &val)
Implementation of an homogeneous matrix and operations on such kind of matrices.
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.
vpMatrix getCovarianceMatrix() const
Class that defines what is a cylinder.
void setCovarianceComputation(const bool &flag)
Implementation of column vector and the associated operations.
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.
void addSpecificFeature(RetType(*fct_ptr)(ArgsFunc...), Args &&... args)