38 #include <visp3/core/vpDebug.h>
39 #include <visp3/core/vpHomogeneousMatrix.h>
40 #include <visp3/core/vpMomentCommon.h>
41 #include <visp3/core/vpMomentDatabase.h>
42 #include <visp3/core/vpMomentObject.h>
43 #include <visp3/core/vpPlane.h>
44 #include <visp3/visual_features/vpFeatureMomentCommon.h>
45 #include <visp3/vs/vpServo.h>
50 #ifdef ENABLE_VISP_NAMESPACE
60 void planeToABC(
const vpPlane &pl,
double &A,
double &B,
double &C);
61 int test(
double x,
double y,
double z,
double alpha);
67 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
70 for (
double i = -0.2; i < 0.2; i += 0.1) {
71 for (
double j = -0.2; j < 0.2; j += 0.1) {
73 for (
double l = 0.5; l < 1.5; l += 0.1) {
74 sum += test(i, j, l, k);
85 std::cout <<
"Catch an exception: " << e << std::endl;
89 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
94 int test(
double x,
double y,
double z,
double alpha)
106 initScene(cMo, cdMo, src, dst);
109 vpMatrix mat = execute(cMo, cdMo, src, dst);
111 if (fabs(mat[0][0] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
113 if (fabs(mat[0][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
115 if (fabs(mat[0][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
118 if (fabs(mat[1][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
120 if (fabs(mat[1][1] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
122 if (fabs(mat[1][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
125 if (fabs(mat[2][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
127 if (fabs(mat[2][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
129 if (fabs(mat[2][2] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
131 if (fabs(mat[2][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
134 if (fabs(mat[3][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
136 if (fabs(mat[3][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
138 if (fabs(mat[3][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
140 if (fabs(mat[3][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
143 if (fabs(mat[4][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
145 if (fabs(mat[4][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
147 if (fabs(mat[4][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
149 if (fabs(mat[4][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
152 if (fabs(mat[5][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
154 if (fabs(mat[5][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
156 if (fabs(mat[5][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
158 if (fabs(mat[5][5] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
167 std::vector<vpPoint> src_pts;
168 std::vector<vpPoint> dst_pts;
170 double x[5] = { 0.2, 0.2, -0.2, -0.2, 0.2 };
171 double y[5] = { -0.1, 0.1, 0.1, -0.1, -0.1 };
174 for (
int i = 0; i < nbpoints; i++) {
177 src_pts.push_back(p);
182 for (
int i = 0; i < nbpoints; i++) {
185 dst_pts.push_back(p);
211 planeToABC(pl, A, B, C);
215 planeToABC(pl, Ad, Bd, Cd);
233 moments.updateAll(src);
234 momentsDes.updateAll(dst);
236 featureMoments.updateAll(A, B, C);
237 featureMomentsDes.updateAll(Ad, Bd, Cd);
243 task.
addFeature(featureMoments.getFeatureGravityNormalized(), featureMomentsDes.getFeatureGravityNormalized());
244 task.
addFeature(featureMoments.getFeatureAn(), featureMomentsDes.getFeatureAn());
246 task.
addFeature(featureMoments.getFeatureCInvariant(), featureMomentsDes.getFeatureCInvariant(),
247 (1 << 10) | (1 << 11));
248 task.
addFeature(featureMoments.getFeatureAlpha(), featureMomentsDes.getFeatureAlpha());
257 void planeToABC(
const vpPlane &pl,
double &A,
double &B,
double &C)
error that can be emitted by ViSP classes.
This class allows to access common vpFeatureMoments in a pre-filled database.
Implementation of an homogeneous matrix and operations on such kind of matrices.
void extract(vpRotationMatrix &R) const
static double rad(double deg)
Implementation of a matrix and operations on matrices.
This class initializes and allows access to commonly used moments.
static std::vector< double > getMu3(vpMomentObject &object)
static double getAlpha(vpMomentObject &object)
static double getSurface(vpMomentObject &object)
Class for generic objects.
void setType(vpObjectType input_type)
void fromVector(std::vector< vpPoint > &points)
This class defines the container for a plane geometrical structure.
void changeFrame(const vpHomogeneousMatrix &cMo)
void setABCD(double a, double b, double c, double d)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
void addFeature(vpBasicFeature &s_cur, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
void setServo(const vpServoType &servo_type)
vpMatrix computeInteractionMatrix()
vpColVector computeControlLaw()
vpServoIteractionMatrixType
Class that consider the case of a translation vector.