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> 56 void planeToABC(
const vpPlane &pl,
double &A,
double &B,
double &C);
57 int test(
double x,
double y,
double z,
double alpha);
63 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)) 66 for (
double i = -0.2; i < 0.2; i += 0.1) {
67 for (
double j = -0.2; j < 0.2; j += 0.1) {
69 for (
double l = 0.5; l < 1.5; l += 0.1) {
70 sum += test(i, j, l, k);
80 std::cout <<
"Catch an exception: " << e << std::endl;
84 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
89 int test(
double x,
double y,
double z,
double alpha)
101 initScene(cMo, cdMo, src, dst);
104 vpMatrix mat = execute(cMo, cdMo, src, dst);
106 if (fabs(mat[0][0] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
108 if (fabs(mat[0][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
110 if (fabs(mat[0][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
113 if (fabs(mat[1][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
115 if (fabs(mat[1][1] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
117 if (fabs(mat[1][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
120 if (fabs(mat[2][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
122 if (fabs(mat[2][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
124 if (fabs(mat[2][2] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
126 if (fabs(mat[2][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
129 if (fabs(mat[3][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
131 if (fabs(mat[3][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
133 if (fabs(mat[3][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
135 if (fabs(mat[3][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
138 if (fabs(mat[4][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
140 if (fabs(mat[4][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
142 if (fabs(mat[4][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
144 if (fabs(mat[4][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
147 if (fabs(mat[5][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
149 if (fabs(mat[5][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
151 if (fabs(mat[5][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
153 if (fabs(mat[5][5] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
162 std::vector<vpPoint> src_pts;
163 std::vector<vpPoint> dst_pts;
165 double x[5] = {0.2, 0.2, -0.2, -0.2, 0.2};
166 double y[5] = {-0.1, 0.1, 0.1, -0.1, -0.1};
169 for (
int i = 0; i < nbpoints; i++) {
172 src_pts.push_back(p);
177 for (
int i = 0; i < nbpoints; i++) {
180 dst_pts.push_back(p);
207 planeToABC(pl, A, B, C);
211 planeToABC(pl, Ad, Bd, Cd);
229 moments.updateAll(src);
230 momentsDes.updateAll(dst);
232 featureMoments.updateAll(A, B, C);
233 featureMomentsDes.updateAll(Ad, Bd, Cd);
239 task.
addFeature(featureMoments.getFeatureGravityNormalized(), featureMomentsDes.getFeatureGravityNormalized());
240 task.
addFeature(featureMoments.getFeatureAn(), featureMomentsDes.getFeatureAn());
242 task.
addFeature(featureMoments.getFeatureCInvariant(), featureMomentsDes.getFeatureCInvariant(),
243 (1 << 10) | (1 << 11));
244 task.
addFeature(featureMoments.getFeatureAlpha(), featureMomentsDes.getFeatureAlpha());
253 void planeToABC(
const vpPlane &pl,
double &A,
double &B,
double &C)
Implementation of a matrix and operations on matrices.
Implementation of an homogeneous matrix and operations on such kind of matrices.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
This class allows to access common vpFeatureMoments in a pre-filled database.
error that can be emited by ViSP classes.
Class for generic objects.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
vpMatrix computeInteractionMatrix()
vpColVector computeControlLaw()
void changeFrame(const vpHomogeneousMatrix &cMo)
static std::vector< double > getMu3(vpMomentObject &object)
void extract(vpRotationMatrix &R) const
vpServoIteractionMatrixType
void setABCD(double a, double b, double c, double d)
void fromVector(std::vector< vpPoint > &points)
static double getSurface(vpMomentObject &object)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static double rad(double deg)
This class initializes and allows access to commonly used moments.
static double getAlpha(vpMomentObject &object)
void setType(vpObjectType input_type)
This class defines the container for a plane geometrical structure.
void setServo(const vpServoType &servo_type)
Class that consider the case of a translation vector.