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>
60 bool found_moment_gravity;
61 bool found_moment_surface_normalized;
63 bool found_featuremoment_gravity;
64 bool found_featuremoment_surfacenormalized;
67 moments.
get(
"vpMomentAreaNormalized", found_moment_surface_normalized));
75 if (!found_moment_surface_normalized)
77 if (!found_moment_gravity)
80 if (!found_featuremoment_gravity)
82 if (!found_featuremoment_surfacenormalized)
89 momentSurfaceNormalized.
get()[0] * featureMomentGravity.
interaction(1);
91 momentSurfaceNormalized.
get()[0] * featureMomentGravity.
interaction(2);
98 #include <visp3/core/vpMomentAreaNormalized.h>
99 #include <visp3/core/vpMomentCentered.h>
100 #include <visp3/core/vpMomentGravityCenter.h>
101 #include <visp3/core/vpMomentObject.h>
102 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
103 #include <visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h>
116 bool found_moment_surface_normalized;
117 bool found_moment_gravity;
118 bool found_moment_centered;
125 moments.
get(
"vpMomentAreaNormalized", found_moment_surface_normalized));
127 if (!found_moment_surface_normalized)
129 if (!found_moment_gravity)
131 if (!found_moment_centered)
138 double n11 = momentCentered.
get(1, 1) / momentObject.
get(0, 0);
139 double n20 = momentCentered.
get(2, 0) / momentObject.
get(0, 0);
140 double n02 = momentCentered.
get(0, 2) / momentObject.
get(0, 0);
141 double n10 = momentCentered.
get(1, 0) / momentObject.
get(0, 0);
142 double n01 = momentCentered.
get(0, 1) / momentObject.
get(0, 0);
143 double n03 = momentCentered.
get(0, 3) / momentObject.
get(0, 0);
145 double Xg = momentGravity.
getXg();
146 double Yg = momentGravity.
getYg();
148 double An = momentSurfaceNormalized.
get()[0];
153 double Xnvx, Xnvy, Xnvz, Xnwx, Xnwy;
154 double Ynvx, Ynvy, Ynvz, Ynwx, Ynwy;
157 double a = momentCentered.
get(2, 0) + momentCentered.
get(0, 2);
159 double e11 = momentCentered.
get(1, 1) / a;
160 double e12 = momentCentered.
get(1, 2) / a;
161 double e21 = momentCentered.
get(2, 1) / a;
162 double e30 = momentCentered.
get(3, 0) / a;
164 double NA = n20 + n02;
166 Xnvx =
B * Xn * e11 - Yn *
B - An *
C - n02 *
A * Xn / NA;
167 Xnvy =
A * Xn * e11 + n02 *
B * Xn / NA;
169 Xnwx = An * e11 * NA + Yn * n10 - Xn * Xg * e11 + Xn * n01 + Xn * n10 * e11 - Xn * e21 +
170 (-Xn * n03 + (Xn * n01 - Yn * Xg) * n02) / NA;
171 Xnwy = -An * NA + Xn * e12 + Xn * Xg - An + e11 * Xg * Yn - Xn * n01 * e11 - 2 * Xn * n10 + Xn * e30 + n02 * An +
172 (-Xn * Xg + Xn * n10) * n02 / NA;
174 Ynvx = (Yn - n02 * Yn / NA) *
A + Yn * e11 *
B;
175 Ynvy = (-Xn + e11 * Yn) *
A + (-Yn + n02 * Yn / NA) *
B - An *
C;
177 Ynwx = n02 * An + Yn * n10 * e11 - e11 * Xg * Yn + An - Yn * e21 + Yn * n01 +
178 (-Yn * n03 + (Yn * n01 - Yn * Yg) * n02) / NA;
179 Ynwy = -An * e11 * NA + Yn * e11 * Yg - Yn * n01 * e11 + Yn * Xg + Yn * e12 + Yn * e30 - Xn * n01 - 2 * Yn * n10 +
180 (Yn * n10 - Yn * Xg) * n02 / NA;
184 Xnvx = -An *
C -
A * Xn - Yn *
B;
185 Xnvy = (0.5) *
B * Xn;
187 Xnwx = (0.5 * (8. * n10 - Xg)) * Yn + 4. * An * n11 + 4. * n01 * Xn;
188 Xnwy = (0.5 * (-2. - 8. * n20)) * An + (0.5) * Xn * (-8. * n10 + Xg);
190 Ynvx = (0.5) *
A * Yn;
191 Ynvy = -(0.5) *
B * Yn -
C * An -
A * Xn;
193 Ynwx = (0.5) * Yn * (8. * n01 - Yg) + (.5 * (2. + 8. * n02)) * An;
194 Ynwy = (0.5 * (-8. * n10 + Xg)) * Yn - 4. * An * n11 - 4. * n01 * Xn;
197 Ynvz = -
A * Ynwy + (-An + Ynwx) *
B;
198 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