39 #include <visp3/core/vpConfig.h> 41 #ifdef VISP_MOMENTS_COMBINE_MATRICES 46 #include <visp3/core/vpMomentAreaNormalized.h> 47 #include <visp3/core/vpMomentCentered.h> 48 #include <visp3/core/vpMomentGravityCenter.h> 49 #include <visp3/core/vpMomentObject.h> 50 #include <visp3/visual_features/vpFeatureMomentAreaNormalized.h> 51 #include <visp3/visual_features/vpFeatureMomentDatabase.h> 52 #include <visp3/visual_features/vpFeatureMomentGravityCenter.h> 53 #include <visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h> 66 bool found_moment_gravity;
67 bool found_moment_surface_normalized;
69 bool found_featuremoment_gravity;
70 bool found_featuremoment_surfacenormalized;
73 moments.
get(
"vpMomentAreaNormalized", found_moment_surface_normalized));
81 if (!found_moment_surface_normalized)
83 if (!found_moment_gravity)
86 if (!found_featuremoment_gravity)
88 if (!found_featuremoment_surfacenormalized)
95 momentSurfaceNormalized.
get()[0] * featureMomentGravity.
interaction(1);
97 momentSurfaceNormalized.
get()[0] * featureMomentGravity.
interaction(2);
105 #include <visp3/core/vpMomentAreaNormalized.h> 106 #include <visp3/core/vpMomentCentered.h> 107 #include <visp3/core/vpMomentGravityCenter.h> 108 #include <visp3/core/vpMomentObject.h> 109 #include <visp3/visual_features/vpFeatureMomentDatabase.h> 110 #include <visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h> 123 bool found_moment_surface_normalized;
124 bool found_moment_gravity;
125 bool found_moment_centered;
132 moments.
get(
"vpMomentAreaNormalized", found_moment_surface_normalized));
134 if (!found_moment_surface_normalized)
136 if (!found_moment_gravity)
138 if (!found_moment_centered)
145 double n11 = momentCentered.
get(1, 1) / momentObject.
get(0, 0);
146 double n20 = momentCentered.
get(2, 0) / momentObject.
get(0, 0);
147 double n02 = momentCentered.
get(0, 2) / momentObject.
get(0, 0);
148 double n10 = momentCentered.
get(1, 0) / momentObject.
get(0, 0);
149 double n01 = momentCentered.
get(0, 1) / momentObject.
get(0, 0);
150 double n03 = momentCentered.
get(0, 3) / momentObject.
get(0, 0);
152 double Xg = momentGravity.
getXg();
153 double Yg = momentGravity.
getYg();
155 double An = momentSurfaceNormalized.
get()[0];
160 double Xnvx, Xnvy, Xnvz, Xnwx, Xnwy;
161 double Ynvx, Ynvy, Ynvz, Ynwx, Ynwy;
164 double a = momentCentered.
get(2, 0) + momentCentered.
get(0, 2);
166 double e11 = momentCentered.
get(1, 1) / a;
167 double e12 = momentCentered.
get(1, 2) / a;
168 double e21 = momentCentered.
get(2, 1) / a;
169 double e30 = momentCentered.
get(3, 0) / a;
171 double NA = n20 + n02;
173 Xnvx =
B * Xn * e11 - Yn *
B - An *
C - n02 *
A * Xn / NA;
174 Xnvy =
A * Xn * e11 + n02 *
B * Xn / NA;
176 Xnwx = An * e11 * NA + Yn * n10 - Xn * Xg * e11 + Xn * n01 + Xn * n10 * e11 - Xn * e21 +
177 (-Xn * n03 + (Xn * n01 - Yn * Xg) * n02) / NA;
178 Xnwy = -An * NA + Xn * e12 + Xn * Xg - An + e11 * Xg * Yn - Xn * n01 * e11 - 2 * Xn * n10 + Xn * e30 + n02 * An +
179 (-Xn * Xg + Xn * n10) * n02 / NA;
181 Ynvx = (Yn - n02 * Yn / NA) *
A + Yn * e11 *
B;
182 Ynvy = (-Xn + e11 * Yn) *
A + (-Yn + n02 * Yn / NA) *
B - An *
C;
184 Ynwx = n02 * An + Yn * n10 * e11 - e11 * Xg * Yn + An - Yn * e21 + Yn * n01 +
185 (-Yn * n03 + (Yn * n01 - Yn * Yg) * n02) / NA;
186 Ynwy = -An * e11 * NA + Yn * e11 * Yg - Yn * n01 * e11 + Yn * Xg + Yn * e12 + Yn * e30 - Xn * n01 - 2 * Yn * n10 +
187 (Yn * n10 - Yn * Xg) * n02 / NA;
190 Xnvx = -An *
C -
A * Xn - Yn *
B;
191 Xnvy = (0.5) * B * Xn;
193 Xnwx = (0.5 * (8. * n10 - Xg)) * Yn + 4. * An * n11 + 4. * n01 * Xn;
194 Xnwy = (0.5 * (-2. - 8. * n20)) * An + (0.5) * Xn * (-8. * n10 + Xg);
196 Ynvx = (0.5) *
A * Yn;
197 Ynvy = -(0.5) * B * Yn -
C * An -
A * Xn;
199 Ynwx = (0.5) * Yn * (8. * n01 - Yg) + (.5 * (2. + 8. * n02)) * An;
200 Ynwy = (0.5 * (-8. * n10 + Xg)) * Yn - 4. * An * n11 - 4. * n01 * Xn;
203 Ynvz = -
A * Ynwy + (-An + Ynwx) *
B;
204 Xnvz = -
A * An -
A * Xnwy +
B * Xnwx;
Class handling the normalized surface moment that is invariant in scale and used to estimate depth...
const std::vector< double > & get() const
error that can be emited by ViSP classes.
Class for generic objects.
const std::vector< double > & get() const
std::vector< vpMatrix > interaction_matrices
Functionality computation for normalized surface moment feature. Computes the interaction matrix asso...
void compute_interaction()
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
const vpMoment & get(const char *type, bool &found) const
vpMomentDatabase & moments
This class defines the double-indexed centered moment descriptor .
double get(unsigned int i, unsigned int j) const
Class describing 2D gravity center moment.
vpObjectType getType() const
const std::vector< double > & get() const
vpFeatureMomentDatabase * featureMomentsDataBase
Used to indicate that a parameter is not initialized.
const vpMomentObject & getObject() const
Functionality computation for gravity center moment feature. Computes the interaction matrix associat...
vpFeatureMoment & get(const char *type, bool &found)