34 #include <visp3/core/vpConfig.h>
36 #ifdef VISP_MOMENTS_COMBINE_MATRICES
40 #include <visp3/core/vpMomentAreaNormalized.h>
41 #include <visp3/core/vpMomentCentered.h>
42 #include <visp3/core/vpMomentGravityCenter.h>
43 #include <visp3/core/vpMomentObject.h>
44 #include <visp3/visual_features/vpFeatureMomentAreaNormalized.h>
45 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
46 #include <visp3/visual_features/vpFeatureMomentGravityCenter.h>
47 #include <visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h>
61 bool found_moment_gravity;
62 bool found_moment_surface_normalized;
64 bool found_featuremoment_gravity;
65 bool found_featuremoment_surfacenormalized;
68 moments.
get(
"vpMomentAreaNormalized", found_moment_surface_normalized));
76 if (!found_moment_surface_normalized)
78 if (!found_moment_gravity)
81 if (!found_featuremoment_gravity)
83 if (!found_featuremoment_surfacenormalized)
90 momentSurfaceNormalized.
get()[0] * featureMomentGravity.
interaction(1);
92 momentSurfaceNormalized.
get()[0] * featureMomentGravity.
interaction(2);
99 #include <visp3/core/vpMomentAreaNormalized.h>
100 #include <visp3/core/vpMomentCentered.h>
101 #include <visp3/core/vpMomentGravityCenter.h>
102 #include <visp3/core/vpMomentObject.h>
103 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
104 #include <visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h>
117 bool found_moment_surface_normalized;
118 bool found_moment_gravity;
119 bool found_moment_centered;
126 moments.
get(
"vpMomentAreaNormalized", found_moment_surface_normalized));
128 if (!found_moment_surface_normalized)
130 if (!found_moment_gravity)
132 if (!found_moment_centered)
139 double n11 = momentCentered.
get(1, 1) / momentObject.
get(0, 0);
140 double n20 = momentCentered.
get(2, 0) / momentObject.
get(0, 0);
141 double n02 = momentCentered.
get(0, 2) / momentObject.
get(0, 0);
142 double n10 = momentCentered.
get(1, 0) / momentObject.
get(0, 0);
143 double n01 = momentCentered.
get(0, 1) / momentObject.
get(0, 0);
144 double n03 = momentCentered.
get(0, 3) / momentObject.
get(0, 0);
146 double Xg = momentGravity.
getXg();
147 double Yg = momentGravity.
getYg();
149 double An = momentSurfaceNormalized.
get()[0];
154 double Xnvx, Xnvy, Xnvz, Xnwx, Xnwy;
155 double Ynvx, Ynvy, Ynvz, Ynwx, Ynwy;
158 double a = momentCentered.
get(2, 0) + momentCentered.
get(0, 2);
160 double e11 = momentCentered.
get(1, 1) / a;
161 double e12 = momentCentered.
get(1, 2) / a;
162 double e21 = momentCentered.
get(2, 1) / a;
163 double e30 = momentCentered.
get(3, 0) / a;
165 double NA = n20 + n02;
167 Xnvx =
B * Xn * e11 - Yn *
B - An *
C - n02 *
A * Xn / NA;
168 Xnvy =
A * Xn * e11 + n02 *
B * Xn / NA;
170 Xnwx = An * e11 * NA + Yn * n10 - Xn * Xg * e11 + Xn * n01 + Xn * n10 * e11 - Xn * e21 +
171 (-Xn * n03 + (Xn * n01 - Yn * Xg) * n02) / NA;
172 Xnwy = -An * NA + Xn * e12 + Xn * Xg - An + e11 * Xg * Yn - Xn * n01 * e11 - 2 * Xn * n10 + Xn * e30 + n02 * An +
173 (-Xn * Xg + Xn * n10) * n02 / NA;
175 Ynvx = (Yn - n02 * Yn / NA) *
A + Yn * e11 *
B;
176 Ynvy = (-Xn + e11 * Yn) *
A + (-Yn + n02 * Yn / NA) *
B - An *
C;
178 Ynwx = n02 * An + Yn * n10 * e11 - e11 * Xg * Yn + An - Yn * e21 + Yn * n01 +
179 (-Yn * n03 + (Yn * n01 - Yn * Yg) * n02) / NA;
180 Ynwy = -An * e11 * NA + Yn * e11 * Yg - Yn * n01 * e11 + Yn * Xg + Yn * e12 + Yn * e30 - Xn * n01 - 2 * Yn * n10 +
181 (Yn * n10 - Yn * Xg) * n02 / NA;
185 Xnvx = -An *
C -
A * Xn - Yn *
B;
186 Xnvy = (0.5) *
B * Xn;
188 Xnwx = (0.5 * (8. * n10 - Xg)) * Yn + 4. * An * n11 + 4. * n01 * Xn;
189 Xnwy = (0.5 * (-2. - 8. * n20)) * An + (0.5) * Xn * (-8. * n10 + Xg);
191 Ynvx = (0.5) *
A * Yn;
192 Ynvy = -(0.5) *
B * Yn -
C * An -
A * Xn;
194 Ynwx = (0.5) * Yn * (8. * n01 - Yg) + (.5 * (2. + 8. * n02)) * An;
195 Ynwy = (0.5 * (-8. * n10 + Xg)) * Yn - 4. * An * n11 - 4. * n01 * Xn;
198 Ynvz = -
A * Ynwy + (-An + Ynwx) *
B;
199 Xnvz = -
A * An -
A * Xnwy +
B * Xnwx;
error that can be emitted by ViSP classes.
@ notInitialized
Used to indicate that a parameter is not initialized.
Functionality computation for normalized surface moment feature. Computes the interaction matrix asso...
vpFeatureMoment & get(const std::string &feature_name, bool &found)
void compute_interaction() VP_OVERRIDE
Functionality computation for gravity center moment feature. Computes the interaction matrix associat...
std::vector< vpMatrix > interaction_matrices
vpFeatureMomentDatabase * featureMomentsDataBase
vpMomentDatabase & moments
vpMatrix interaction(unsigned int select=FEATURE_ALL) VP_OVERRIDE
Class handling the normalized surface moment that is invariant in scale and used to estimate depth.
This class defines the double-indexed centered moment descriptor .
double get(unsigned int i, unsigned int j) const
const vpMoment & get(const std::string &moment_name, bool &found) const
Class describing 2D gravity center moment.
const std::vector< double > & get() const
Class for generic objects.
const std::vector< double > & get() const
vpObjectType getType() const
const vpMomentObject & getObject() const
const std::vector< double > & get() const