33 #include <visp3/core/vpMomentObject.h>
34 #ifdef VISP_MOMENTS_COMBINE_MATRICES
35 #include <visp3/core/vpMomentCInvariant.h>
36 #include <visp3/core/vpMomentCentered.h>
37 #include <visp3/visual_features/vpFeatureMomentBasic.h>
38 #include <visp3/visual_features/vpFeatureMomentCInvariant.h>
39 #include <visp3/visual_features/vpFeatureMomentCentered.h>
41 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
57 std::vector<vpMatrix> LI(16);
58 bool found_moment_centered;
59 bool found_moment_cinvariant;
60 bool found_FeatureMoment_centered;
61 bool found_featuremoment_basic;
74 if (!found_featuremoment_basic)
77 if (!found_moment_centered)
79 if (!found_moment_cinvariant)
81 if (!found_FeatureMoment_centered)
85 for (
int i = 0; i < 6; i++)
88 LI[1] = -featureMomentCentered.
interaction(2, 0) * momentCentered.
get(0, 2) -
89 momentCentered.
get(2, 0) * featureMomentCentered.
interaction(0, 2) +
90 2 * momentCentered.
get(1, 1) * featureMomentCentered.
interaction(1, 1);
92 LI[2] = 2 * (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)) *
94 8 * momentCentered.
get(1, 1) * featureMomentCentered.
interaction(1, 1);
96 LI[3] = 2 * (momentCentered.
get(3, 0) - 3 * momentCentered.
get(1, 2)) *
98 2 * (3 * momentCentered.
get(2, 1) - momentCentered.
get(0, 3)) *
101 LI[4] = 2 * (momentCentered.
get(3, 0) + momentCentered.
get(1, 2)) *
103 2 * (momentCentered.
get(2, 1) + momentCentered.
get(0, 3)) *
106 LI[5] = -2 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(3, 0) +
107 6 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) *
109 4 * pow(momentCentered.
get(1, 2), 3) * featureMomentCentered.
interaction(3, 0) +
110 6 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(3, 0) *
112 12 * momentCentered.
get(0, 3) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(2, 1) +
113 6 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(2, 1) +
114 6 * momentCentered.
get(0, 3) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
116 12 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(1, 2) +
117 6 * momentCentered.
get(1, 2) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(1, 2) -
118 2 * momentCentered.
get(0, 3) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(0, 3) +
119 6 * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
121 4 * pow(momentCentered.
get(2, 1), 3) * featureMomentCentered.
interaction(0, 3);
123 LI[6] = 6 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(3, 0) +
124 4 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(3, 0) -
125 6 * momentCentered.
get(1, 2) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(3, 0) -
126 6 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) *
128 2 * pow(momentCentered.
get(1, 2), 3) * featureMomentCentered.
interaction(3, 0) -
129 12 * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
131 6 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(3, 0) *
133 12 * pow(momentCentered.
get(2, 1), 3) * featureMomentCentered.
interaction(2, 1) +
134 6 * momentCentered.
get(0, 3) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(2, 1) +
135 6 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(2, 1) -
136 6 * momentCentered.
get(0, 3) * pow(momentCentered.
get(1, 2), 2) * featureMomentCentered.
interaction(2, 1) +
137 6 * momentCentered.
get(1, 2) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(1, 2) -
138 6 * pow(momentCentered.
get(2, 1), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(1, 2) -
139 6 * momentCentered.
get(0, 3) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
141 6 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(1, 2) -
142 12 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) *
144 12 * pow(momentCentered.
get(1, 2), 3) * featureMomentCentered.
interaction(1, 2) +
145 4 * momentCentered.
get(0, 3) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(0, 3) -
146 6 * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
148 2 * pow(momentCentered.
get(2, 1), 3) * featureMomentCentered.
interaction(0, 3) +
149 6 * momentCentered.
get(0, 3) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(0, 3) -
150 6 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(0, 3);
152 LI[7] = -3 * momentCentered.
get(0, 3) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(3, 0) +
153 6 * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
155 2 * pow(momentCentered.
get(2, 1), 3) * featureMomentCentered.
interaction(3, 0) -
156 3 * momentCentered.
get(0, 3) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(3, 0) +
157 6 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(3, 0) +
158 3 * momentCentered.
get(0, 3) * pow(momentCentered.
get(1, 2), 2) * featureMomentCentered.
interaction(3, 0) +
159 pow(momentCentered.
get(0, 3), 3) * featureMomentCentered.
interaction(3, 0) +
160 3 * momentCentered.
get(1, 2) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(2, 1) -
161 6 * pow(momentCentered.
get(2, 1), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(2, 1) -
162 6 * momentCentered.
get(0, 3) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
164 6 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(2, 1) -
165 9 * momentCentered.
get(1, 2) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(2, 1) -
166 12 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) *
168 3 * pow(momentCentered.
get(1, 2), 3) * featureMomentCentered.
interaction(2, 1) -
169 3 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(1, 2) * featureMomentCentered.
interaction(2, 1) +
170 3 * momentCentered.
get(2, 1) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(1, 2) +
171 12 * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
173 6 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(3, 0) *
175 3 * pow(momentCentered.
get(2, 1), 3) * featureMomentCentered.
interaction(1, 2) -
176 6 * momentCentered.
get(0, 3) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(1, 2) +
177 9 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(1, 2) -
178 3 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(1, 2) +
179 6 * momentCentered.
get(0, 3) * pow(momentCentered.
get(1, 2), 2) * featureMomentCentered.
interaction(1, 2) -
180 pow(momentCentered.
get(3, 0), 3) * featureMomentCentered.
interaction(0, 3) -
181 3 * pow(momentCentered.
get(2, 1), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(0, 3) +
182 3 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(0, 3) +
183 3 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(0, 3) -
184 6 * momentCentered.
get(1, 2) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(0, 3) -
185 6 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) *
187 2 * pow(momentCentered.
get(1, 2), 3) * featureMomentCentered.
interaction(0, 3);
189 LI[8] = -2 * momentCentered.
get(3, 0) * momentCentered.
get(2, 1) * momentCentered.
get(0, 3) *
191 6 * momentCentered.
get(3, 0) * momentCentered.
get(2, 1) * momentCentered.
get(1, 2) *
193 6 * featureMomentCentered.
interaction(3, 0) * momentCentered.
get(2, 1) * momentCentered.
get(0, 3) *
194 momentCentered.
get(1, 2) -
195 6 * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(2, 1) * momentCentered.
get(0, 3) *
196 momentCentered.
get(1, 2) -
197 6 * momentCentered.
get(3, 0) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(0, 3) *
198 momentCentered.
get(1, 2) -
199 6 * momentCentered.
get(3, 0) * momentCentered.
get(2, 1) * momentCentered.
get(0, 3) *
201 2 * momentCentered.
get(3, 0) * momentCentered.
get(1, 2) * momentCentered.
get(0, 3) *
203 6 * momentCentered.
get(2, 1) * momentCentered.
get(1, 2) * momentCentered.
get(0, 3) *
205 pow((
double)momentCentered.
get(3, 0), (
double)3) * featureMomentCentered.
interaction(1, 2) +
206 3 * featureMomentCentered.
interaction(3, 0) * pow((
double)momentCentered.
get(1, 2), (
double)3) +
207 6 * pow((
double)momentCentered.
get(2, 1), (
double)3) * featureMomentCentered.
interaction(0, 3) -
208 featureMomentCentered.
interaction(2, 1) * pow((
double)momentCentered.
get(0, 3), (
double)3) +
209 3 * featureMomentCentered.
interaction(2, 1) * pow((
double)momentCentered.
get(1, 2), (
double)2) *
210 momentCentered.
get(0, 3) +
211 18 * pow((
double)momentCentered.
get(2, 1), (
double)2) * momentCentered.
get(0, 3) *
213 pow((
double)momentCentered.
get(3, 0), (
double)2) * featureMomentCentered.
interaction(2, 1) *
214 momentCentered.
get(0, 3) +
215 9 * momentCentered.
get(3, 0) * pow((
double)momentCentered.
get(1, 2), (
double)2) *
217 4 * pow((
double)momentCentered.
get(3, 0), (
double)2) * momentCentered.
get(1, 2) *
219 2 * pow((
double)momentCentered.
get(1, 2), (
double)2) * momentCentered.
get(0, 3) *
221 4 * momentCentered.
get(3, 0) * pow((
double)momentCentered.
get(1, 2), (
double)2) *
223 2 * momentCentered.
get(1, 2) * pow((
double)momentCentered.
get(0, 3), (
double)2) *
225 4 * momentCentered.
get(2, 1) * pow((
double)momentCentered.
get(0, 3), (
double)2) *
227 3 * momentCentered.
get(3, 0) * pow((
double)momentCentered.
get(2, 1), (
double)2) *
229 3 * pow((
double)momentCentered.
get(3, 0), (
double)2) * momentCentered.
get(1, 2) *
231 momentCentered.
get(3, 0) * featureMomentCentered.
interaction(1, 2) *
232 pow((
double)momentCentered.
get(0, 3), (
double)2) -
233 4 * pow((
double)momentCentered.
get(2, 1), (
double)2) * momentCentered.
get(0, 3) *
235 3 * momentCentered.
get(2, 1) * pow((
double)momentCentered.
get(0, 3), (
double)2) *
237 2 * momentCentered.
get(3, 0) * pow((
double)momentCentered.
get(2, 1), (
double)2) *
239 2 * pow((
double)momentCentered.
get(3, 0), (
double)2) * momentCentered.
get(2, 1) *
241 3 * featureMomentCentered.
interaction(3, 0) * pow((
double)momentCentered.
get(2, 1), (
double)2) *
242 momentCentered.
get(1, 2) -
243 pow((
double)momentCentered.
get(3, 0), (
double)2) * momentCentered.
get(2, 1) *
245 3 * momentCentered.
get(2, 1) * pow((
double)momentCentered.
get(1, 2), (
double)2) *
247 featureMomentCentered.
interaction(3, 0) * momentCentered.
get(1, 2) *
248 pow((
double)momentCentered.
get(0, 3), (
double)2);
250 LI[9] = 4 * pow(momentCentered.
get(3, 0), 3) * featureMomentCentered.
interaction(3, 0) +
251 18 * momentCentered.
get(1, 2) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(3, 0) +
252 12 * momentCentered.
get(0, 3) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
254 18 * pow(momentCentered.
get(1, 2), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(3, 0) +
255 4 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(3, 0) +
256 18 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) *
258 6 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(1, 2) * featureMomentCentered.
interaction(3, 0) +
259 6 * momentCentered.
get(0, 3) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(2, 1) +
260 18 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(3, 0) *
262 18 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(2, 1) +
263 6 * pow(momentCentered.
get(0, 3), 3) * featureMomentCentered.
interaction(2, 1) +
264 6 * pow(momentCentered.
get(3, 0), 3) * featureMomentCentered.
interaction(1, 2) +
265 18 * momentCentered.
get(1, 2) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(1, 2) +
266 18 * momentCentered.
get(0, 3) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
268 6 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(3, 0) * featureMomentCentered.
interaction(1, 2) +
269 6 * momentCentered.
get(2, 1) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(0, 3) +
270 4 * momentCentered.
get(0, 3) * pow(momentCentered.
get(3, 0), 2) * featureMomentCentered.
interaction(0, 3) +
271 18 * momentCentered.
get(1, 2) * momentCentered.
get(2, 1) * momentCentered.
get(3, 0) *
273 12 * momentCentered.
get(0, 3) * momentCentered.
get(1, 2) * momentCentered.
get(3, 0) *
275 18 * momentCentered.
get(0, 3) * pow(momentCentered.
get(2, 1), 2) * featureMomentCentered.
interaction(0, 3) +
276 18 * pow(momentCentered.
get(0, 3), 2) * momentCentered.
get(2, 1) * featureMomentCentered.
interaction(0, 3) +
277 4 * pow(momentCentered.
get(0, 3), 3) * featureMomentCentered.
interaction(0, 3);
279 LI[10] = featureMomentCentered.
interaction(4, 0) * momentCentered.
get(0, 4) +
280 momentCentered.
get(4, 0) * featureMomentCentered.
interaction(0, 4) -
281 4 * featureMomentCentered.
interaction(3, 1) * momentCentered.
get(1, 3) -
282 4 * momentCentered.
get(3, 1) * featureMomentCentered.
interaction(1, 3) +
283 6 * momentCentered.
get(2, 2) * featureMomentCentered.
interaction(2, 2);
285 LI[11] = -3 * featureMomentCentered.
interaction(4, 0) * momentCentered.
get(2, 2) -
286 3 * momentCentered.
get(4, 0) * featureMomentCentered.
interaction(2, 2) -
287 2 * featureMomentCentered.
interaction(4, 0) * momentCentered.
get(0, 4) -
288 2 * momentCentered.
get(4, 0) * featureMomentCentered.
interaction(0, 4) +
289 6 * momentCentered.
get(3, 1) * featureMomentCentered.
interaction(3, 1) +
290 2 * featureMomentCentered.
interaction(3, 1) * momentCentered.
get(1, 3) +
291 2 * momentCentered.
get(3, 1) * featureMomentCentered.
interaction(1, 3) -
292 3 * featureMomentCentered.
interaction(2, 2) * momentCentered.
get(0, 4) -
293 3 * momentCentered.
get(2, 2) * featureMomentCentered.
interaction(0, 4) +
294 6 * momentCentered.
get(1, 3) * featureMomentCentered.
interaction(1, 3);
296 LI[12] = 6 * momentCentered.
get(4, 0) * featureMomentCentered.
interaction(4, 0) +
297 12 * featureMomentCentered.
interaction(4, 0) * momentCentered.
get(2, 2) +
298 12 * momentCentered.
get(4, 0) * featureMomentCentered.
interaction(2, 2) +
299 2 * featureMomentCentered.
interaction(4, 0) * momentCentered.
get(0, 4) +
300 2 * momentCentered.
get(4, 0) * featureMomentCentered.
interaction(0, 4) +
301 16 * featureMomentCentered.
interaction(3, 1) * momentCentered.
get(1, 3) +
302 16 * momentCentered.
get(3, 1) * featureMomentCentered.
interaction(1, 3) +
303 12 * featureMomentCentered.
interaction(2, 2) * momentCentered.
get(0, 4) +
304 12 * momentCentered.
get(2, 2) * featureMomentCentered.
interaction(0, 4) +
305 6 * momentCentered.
get(0, 4) * featureMomentCentered.
interaction(0, 4);
307 LI[13] = 2 * (momentCentered.
get(5, 0) + 2 * momentCentered.
get(3, 2) + momentCentered.
get(1, 4)) *
310 2 * (momentCentered.
get(0, 5) + 2 * momentCentered.
get(2, 3) + momentCentered.
get(4, 1)) *
314 LI[14] = 2 * (momentCentered.
get(5, 0) - 2 * momentCentered.
get(3, 2) - 3 * momentCentered.
get(1, 4)) *
317 2 * (momentCentered.
get(0, 5) - 2 * momentCentered.
get(2, 3) - 3 * momentCentered.
get(4, 1)) *
321 LI[15] = 2 * (momentCentered.
get(5, 0) - 10 * momentCentered.
get(3, 2) + 5 * momentCentered.
get(1, 4)) *
324 2 * (momentCentered.
get(0, 5) - 10 * momentCentered.
get(2, 3) + 5 * momentCentered.
get(4, 1)) *
328 double s3 = momentCInvariant.
getS(3);
329 double s2 = momentCInvariant.
getS(2);
330 double c3 = momentCInvariant.
getC(3);
331 double c2 = momentCInvariant.
getC(2);
332 double I1 = momentCInvariant.
getII(1);
333 double I2 = momentCInvariant.
getII(2);
334 double I3 = momentCInvariant.
getII(3);
338 vpMatrix Lc3 = 2 * (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)) *
340 8 * momentCentered.
get(1, 1) * featureMomentCentered.
interaction(1, 1);
342 4 * momentCentered.
get(1, 1) *
344 vpMatrix LI1 = 2 * (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)) *
346 8 * momentCentered.
get(1, 1) * featureMomentCentered.
interaction(1, 1);
347 vpMatrix LI2 = 2 * (momentCentered.
get(0, 3) - 3 * momentCentered.
get(2, 1)) *
349 2 * (momentCentered.
get(3, 0) - 3 * momentCentered.
get(1, 2)) *
356 a = momentCentered.
get(2, 0) + momentCentered.
get(0, 2);
360 a = momentObject.
get(0, 0);
366 (momentCInvariant.
getI(2) * LI[1] - momentCInvariant.
getI(1) * LI[2]);
368 (momentCInvariant.
getI(4) * LI[3] - momentCInvariant.
getI(3) * LI[4]);
371 (momentCInvariant.
getI(6) * LI[5] - momentCInvariant.
getI(5) * LI[6]);
374 (momentCInvariant.
getI(6) * LI[7] - momentCInvariant.
getI(7) * LI[6]);
377 (momentCInvariant.
getI(6) * LI[8] - momentCInvariant.
getI(8) * LI[6]);
380 (momentCInvariant.
getI(6) * LI[9] - momentCInvariant.
getI(9) * LI[6]);
383 (momentCInvariant.
getI(10) * LI[11] - momentCInvariant.
getI(11) * LI[10]);
386 (momentCInvariant.
getI(10) * LI[12] - momentCInvariant.
getI(12) * LI[10]);
389 (momentCInvariant.
getI(15) * LI[13] - momentCInvariant.
getI(13) * LI[15]);
392 (momentCInvariant.
getI(15) * LI[14] - momentCInvariant.
getI(14) * LI[15]);
394 interaction_matrices[10] = (Lc2 * c3 + c2 * Lc3 + Ls2 * s3 + s2 * Ls3) * sqrt(a) / I1 * pow(I3, -0.3e1 / 0.2e1) +
395 (c2 * c3 + s2 * s3) * pow(a, -0.1e1 / 0.2e1) / I1 * pow(I3, -0.3e1 / 0.2e1) * La / 0.2e1 -
396 (c2 * c3 + s2 * s3) * sqrt(a) * pow(I1, -0.2e1) * pow(I3, -0.3e1 / 0.2e1) * LI1 -
397 0.3e1 / 0.2e1 * (c2 * c3 + s2 * s3) * sqrt(a) / I1 * pow(I3, -0.5e1 / 0.2e1) * LI3;
399 interaction_matrices[11] = (Ls2 * c3 + s2 * Lc3 - Lc2 * s3 - c2 * Ls3) * sqrt(a) / I1 * pow(I3, -0.3e1 / 0.2e1) +
400 (s2 * c3 - c2 * s3) * pow(a, -0.1e1 / 0.2e1) / I1 * pow(I3, -0.3e1 / 0.2e1) * La / 0.2e1 -
401 (s2 * c3 - c2 * s3) * sqrt(a) * pow(I1, -0.2e1) * pow(I3, -0.3e1 / 0.2e1) * LI1 -
402 0.3e1 / 0.2e1 * (s2 * c3 - c2 * s3) * sqrt(a) / I1 * pow(I3, -0.5e1 / 0.2e1) * LI3;
406 (I2 / (I3 * I3 * I3)) * La + (a / (I3 * I3 * I3)) * LI2 - (3 * a * I2 / (I3 * I3 * I3 * I3)) * LI3;
410 #include <visp3/core/vpMomentCInvariant.h>
411 #include <visp3/core/vpMomentCentered.h>
412 #include <visp3/visual_features/vpFeatureMomentBasic.h>
413 #include <visp3/visual_features/vpFeatureMomentCInvariant.h>
414 #include <visp3/visual_features/vpFeatureMomentCentered.h>
416 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
437 bool found_moment_centered;
438 bool found_moment_cinvariant;
439 bool found_FeatureMoment_centered;
440 bool found_featuremoment_basic;
454 if (!found_featuremoment_basic)
456 if (!found_moment_centered)
458 if (!found_moment_cinvariant)
460 if (!found_FeatureMoment_centered)
464 for (
int i = 0; i < 6; i++)
467 double mu30 = momentCentered.
get(3, 0);
468 double mu30_2 = mu30 * mu30;
469 double mu30_3 = mu30_2 * mu30;
471 double mu03 = momentCentered.
get(0, 3);
472 double mu03_2 = mu03 * mu03;
473 double mu03_3 = mu03 * mu03_2;
475 double mu20 = momentCentered.
get(2, 0);
476 double mu02 = momentCentered.
get(0, 2);
477 double mu50 = momentCentered.
get(5, 0);
478 double mu32 = momentCentered.
get(3, 2);
479 double mu14 = momentCentered.
get(1, 4);
480 double mu05 = momentCentered.
get(0, 5);
481 double mu23 = momentCentered.
get(2, 3);
482 double mu41 = momentCentered.
get(4, 1);
483 double mu40 = momentCentered.
get(4, 0);
484 double mu04 = momentCentered.
get(0, 4);
485 double mu31 = momentCentered.
get(3, 1);
486 double mu13 = momentCentered.
get(1, 3);
487 double mu22 = momentCentered.
get(2, 2);
488 double mu21 = momentCentered.
get(2, 1);
489 double mu12 = momentCentered.
get(1, 2);
490 double mu11 = momentCentered.
get(1, 1);
492 double mu12_2 = mu12 * mu12;
493 double mu21_2 = mu21 * mu21;
494 double mu21_3 = mu21 * mu21_2;
495 double mu12_3 = mu12_2 * mu12;
516 LI[1] = -Lmu20 * mu02 - mu20 * Lmu02 + 2 * mu11 * Lmu11;
518 LI[2] = (-2 * mu20 + 2 * mu02) * Lmu02 + 8 * mu11 * Lmu11 + (2 * mu20 - 2 * mu02) * Lmu20;
520 LI[3] = (-6 * mu21 + 2 * mu03) * Lmu03 + (-6 * mu30 + 18 * mu12) * Lmu12 + (18 * mu21 - 6 * mu03) * Lmu21 +
521 (2 * mu30 - 6 * mu12) * Lmu30;
523 LI[4] = (2 * mu21 + 2 * mu03) * Lmu03 + (2 * mu30 + 2 * mu12) * Lmu12 + (2 * mu21 + 2 * mu03) * Lmu21 +
524 (2 * mu30 + 2 * mu12) * Lmu30;
526 LI[5] = (-2 * mu30_2 * mu03 + 6 * mu30 * mu21 * mu12 - 4 * mu21_3) * Lmu03 +
527 (6 * mu30 * mu21 * mu03 - 12 * mu30 * mu12_2 + 6 * mu21_2 * mu12) * Lmu12 +
528 (6 * mu30 * mu12 * mu03 - 12 * mu21_2 * mu03 + 6 * mu21 * mu12_2) * Lmu21 +
529 (-2 * mu30 * mu03_2 - 4 * mu12_3 + 6 * mu21 * mu12 * mu03) * Lmu30;
531 LI[6] = (-6 * mu30 * mu21 * mu12 - 6 * mu21 * mu12_2 + 6 * mu21_2 * mu03 + 2 * mu21_3 + 4 * mu30_2 * mu03) * Lmu03 +
532 (-6 * mu30 * mu21_2 - 6 * mu30 * mu21 * mu03 + 12 * mu12_3 + 6 * mu30_2 * mu12 - 12 * mu21 * mu12 * mu03 +
535 (6 * mu21 * mu03_2 + 6 * mu21_2 * mu03 - 6 * mu30 * mu12 * mu03 + 12 * mu21_3 - 12 * mu30 * mu21 * mu12 -
538 (6 * mu30 * mu12_2 + 2 * mu12_3 + 4 * mu30 * mu03_2 - 6 * mu21_2 * mu12 - 6 * mu21 * mu12 * mu03) * Lmu30;
540 LI[7] = (-6 * mu21_2 * mu12 + 3 * mu30 * mu03_2 - mu30_3 - 3 * mu30 * mu21_2 - 6 * mu21 * mu12 * mu03 +
541 3 * mu30 * mu12_2 + 2 * mu12_3) *
543 (-3 * mu21 * mu03_2 + 12 * mu30 * mu21 * mu12 + 6 * mu30 * mu12 * mu03 + 3 * mu30_2 * mu21 +
544 9 * mu21 * mu12_2 - 6 * mu21_2 * mu03 - 3 * mu21_3 + 6 * mu12_2 * mu03) *
546 (3 * mu30_2 * mu12 - 9 * mu21_2 * mu12 - 12 * mu21 * mu12 * mu03 - 6 * mu30 * mu21 * mu03 -
547 6 * mu30 * mu21_2 + 6 * mu30 * mu12_2 + 3 * mu12_3 - 3 * mu12 * mu03_2) *
549 (6 * mu21 * mu12_2 + 6 * mu30 * mu21 * mu12 - 3 * mu30_2 * mu03 + 3 * mu12_2 * mu03 - 3 * mu21_2 * mu03 -
550 2 * mu21_3 + mu03_3) *
553 LI[8] = (6 * mu21_3 - 2 * mu30 * mu12 * mu03 + 2 * mu12_2 * mu03 + 3 * mu21 * mu12_2 - 6 * mu30 * mu21 * mu12 -
554 mu30_2 * mu21 - 4 * mu21_2 * mu03 - 3 * mu21 * mu03_2) *
556 (2 * mu12 * mu03_2 - 4 * mu30_2 * mu12 + 9 * mu30 * mu12_2 - mu30 * mu03_2 - 6 * mu30 * mu21 * mu03 +
557 3 * mu30 * mu21_2 + 6 * mu21 * mu12 * mu03 - mu30_3) *
559 (18 * mu21_2 * mu03 + 6 * mu30 * mu21 * mu12 - 4 * mu21 * mu03_2 - mu03_3 - mu30_2 * mu03 -
560 6 * mu30 * mu12 * mu03 + 3 * mu12_2 * mu03 + 2 * mu30_2 * mu21) *
562 (-6 * mu21 * mu12 * mu03 - 4 * mu30 * mu12_2 - 2 * mu30 * mu21 * mu03 + 2 * mu30 * mu21_2 + 3 * mu12_3 +
563 3 * mu21_2 * mu12 - 3 * mu30_2 * mu12 - mu12 * mu03_2) *
566 LI[9] = (2 * (2 * mu03 + 3 * mu21)) * (3 * mu03 * mu21 + 3 * mu30 * mu12 + mu30_2 + mu03_2) * Lmu03 +
567 6 * mu30 * (3 * mu03 * mu21 + 3 * mu30 * mu12 + mu30_2 + mu03_2) * Lmu12 +
568 6 * mu03 * (3 * mu03 * mu21 + 3 * mu30 * mu12 + mu30_2 + mu03_2) * Lmu21 +
569 (2 * (2 * mu30 + 3 * mu12)) * (3 * mu03 * mu21 + 3 * mu30 * mu12 + mu30_2 + mu03_2) * Lmu30;
571 LI[10] = Lmu40 * mu04 + mu40 * Lmu04 - 4 * Lmu31 * mu13 - 4 * mu31 * Lmu13 + 6 * mu22 * Lmu22;
573 LI[11] = (-2 * mu40 - 3 * mu22) * Lmu04 + (2 * mu31 + 6 * mu13) * Lmu13 + (-3 * mu04 - 3 * mu40) * Lmu22 +
574 (2 * mu13 + 6 * mu31) * Lmu31 + (-3 * mu22 - 2 * mu04) * Lmu40;
576 LI[12] = (2 * mu40 + 12 * mu22 + 6 * mu04) * Lmu04 + 16 * mu31 * Lmu13 + (12 * mu40 + 12 * mu04) * Lmu22 +
577 16 * Lmu31 * mu13 + (6 * mu40 + 12 * mu22 + 2 * mu04) * Lmu40;
579 LI[13] = (2 * mu05 + 4 * mu23 + 2 * mu41) * Lmu05 + (2 * mu50 + 4 * mu32 + 2 * mu14) * Lmu14 +
580 (4 * mu05 + 8 * mu23 + 4 * mu41) * Lmu23 + (4 * mu50 + 8 * mu32 + 4 * mu14) * Lmu32 +
581 (2 * mu05 + 4 * mu23 + 2 * mu41) * Lmu41 + (2 * mu50 + 4 * mu32 + 2 * mu14) * Lmu50;
583 LI[14] = (2 * mu05 - 4 * mu23 - 6 * mu41) * Lmu05 + (-6 * mu50 + 12 * mu32 + 18 * mu14) * Lmu14 +
584 (-4 * mu05 + 8 * mu23 + 12 * mu41) * Lmu23 + (-4 * mu50 + 8 * mu32 + 12 * mu14) * Lmu32 +
585 (-6 * mu05 + 12 * mu23 + 18 * mu41) * Lmu41 + (2 * mu50 - 4 * mu32 - 6 * mu14) * Lmu50;
587 LI[15] = (2 * mu05 - 20 * mu23 + 10 * mu41) * Lmu05 + (10 * mu50 - 100 * mu32 + 50 * mu14) * Lmu14 +
588 (-20 * mu05 + 200 * mu23 - 100 * mu41) * Lmu23 + (-20 * mu50 + 200 * mu32 - 100 * mu14) * Lmu32 +
589 (10 * mu05 - 100 * mu23 + 50 * mu41) * Lmu41 + (2 * mu50 - 20 * mu32 + 10 * mu14) * Lmu50;
591 double s3 = momentCInvariant.
getS(3);
592 double s2 = momentCInvariant.
getS(2);
593 double c3 = momentCInvariant.
getC(3);
594 double c2 = momentCInvariant.
getC(2);
596 double I1 = momentCInvariant.
getII(1);
597 double I2 = momentCInvariant.
getII(2);
598 double I3 = momentCInvariant.
getII(3);
600 vpMatrix Lmu20__Lmu02 = Lmu20 - Lmu02;
601 double mu20__mu02 = mu20 - mu02;
604 vpMatrix Lc3 = 2 * (mu20__mu02) * (Lmu20__Lmu02)-8. * mu11 * Lmu11;
605 vpMatrix Ls3 = 4 * Lmu11 * (mu20__mu02)+4 * mu11 * (Lmu20__Lmu02);
606 vpMatrix LI1 = 2 * (mu20__mu02) * (Lmu20__Lmu02)+8 * mu11 * Lmu11;
607 vpMatrix LI2 = 2 * (mu03 - 3 * mu21) * (Lc2)+2 * (mu30 - 3 * mu12) * (Ls2);
613 a = momentCentered.
get(2, 0) + momentCentered.
get(0, 2);
617 a = momentObject.
get(0, 0);
629 (momentCInvariant.
getI(2) * LI[1] - momentCInvariant.
getI(1) * LI[2]);
632 (momentCInvariant.
getI(4) * LI[3] - momentCInvariant.
getI(3) * LI[4]);
635 (momentCInvariant.
getI(6) * LI[5] - momentCInvariant.
getI(5) * LI[6]);
638 (momentCInvariant.
getI(6) * LI[7] - momentCInvariant.
getI(7) * LI[6]);
641 (momentCInvariant.
getI(6) * LI[8] - momentCInvariant.
getI(8) * LI[6]);
644 (momentCInvariant.
getI(6) * LI[9] - momentCInvariant.
getI(9) * LI[6]);
647 (momentCInvariant.
getI(10) * LI[11] - momentCInvariant.
getI(11) * LI[10]);
650 (momentCInvariant.
getI(10) * LI[12] - momentCInvariant.
getI(12) * LI[10]);
653 (momentCInvariant.
getI(15) * LI[13] - momentCInvariant.
getI(13) * LI[15]);
656 (momentCInvariant.
getI(15) * LI[14] - momentCInvariant.
getI(14) * LI[15]);
658 interaction_matrices[10] = (Lc2 * c3 + c2 * Lc3 + Ls2 * s3 + s2 * Ls3) * sqrt(a) / I1 * pow(I3, -0.3e1 / 0.2e1) +
659 (c2 * c3 + s2 * s3) * pow(a, -0.1e1 / 0.2e1) / I1 * pow(I3, -0.3e1 / 0.2e1) * La / 0.2e1 -
660 (c2 * c3 + s2 * s3) * sqrt(a) * pow(I1, -0.2e1) * pow(I3, -0.3e1 / 0.2e1) * LI1 -
661 0.3e1 / 0.2e1 * (c2 * c3 + s2 * s3) * sqrt(a) / I1 * pow(I3, -0.5e1 / 0.2e1) * LI3;
663 interaction_matrices[11] = (Ls2 * c3 + s2 * Lc3 - Lc2 * s3 - c2 * Ls3) * sqrt(a) / I1 * pow(I3, -0.3e1 / 0.2e1) +
664 (s2 * c3 - c2 * s3) * pow(a, -0.1e1 / 0.2e1) / I1 * pow(I3, -0.3e1 / 0.2e1) * La / 0.2e1 -
665 (s2 * c3 - c2 * s3) * sqrt(a) * pow(I1, -0.2e1) * pow(I3, -0.3e1 / 0.2e1) * LI1 -
666 0.3e1 / 0.2e1 * (s2 * c3 - c2 * s3) * sqrt(a) / I1 * pow(I3, -0.5e1 / 0.2e1) * LI3;
671 (I2 / (I3 * I3 * I3)) * La + (a / (I3 * I3 * I3)) * LI2 - (3 * a * I2 / (I3 * I3 * I3 * I3)) * LI3;
681 for (
unsigned int i = 1; i < 15; ++i) {
682 os <<
"LI[" << i <<
"] = ";
683 LI[i].matlabPrint(os);
695 for (
unsigned int i = 0; i < 10; ++i) {
696 os <<
"L_c[" << i <<
"] = ";
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
error that can be emitted by ViSP classes.
@ notInitialized
Used to indicate that a parameter is not initialized.
Functionality computation for basic moment feature. Computes the interaction matrix associated with v...
vpMatrix interaction(unsigned int select_one, unsigned int select_two) const
Functionality computation for 2D rotation/translation/scale non-symmetric invariant moment feature....
void compute_interaction() VP_OVERRIDE
void printLsofInvariants(std::ostream &os) const
Functionality computation for centered moment feature. Computes the interaction matrix associated wit...
vpMatrix interaction(unsigned int select_one, unsigned int select_two) const
vpFeatureMoment & get(const std::string &feature_name, bool &found)
std::vector< vpMatrix > interaction_matrices
vpFeatureMomentDatabase * featureMomentsDataBase
vpMomentDatabase & moments
Implementation of a matrix and operations on matrices.
double getI(unsigned int index) const
double getS(unsigned int i) const
double getC(unsigned int i) const
double getII(unsigned int i) const
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 for generic objects.
const std::vector< double > & get() const
vpObjectType getType() const
const vpMomentObject & getObject() const