@@ -283,21 +283,21 @@ void vpMeSite::track(const vpImage<unsigned char> &I, const vpMe *me, const bool
283
283
// array in which likelihood ratios will be stored
284
284
double *likelihood = new double [(2 * range) + 1 ];
285
285
286
+ double threshold = getContrastThreshold ();
287
+
288
+ if (me->getLikelihoodThresholdType () == vpMe::NORMALIZED_THRESHOLD) {
289
+ threshold = 2.0 * threshold;
290
+ }
291
+ else {
292
+ const double n_d = me->getMaskSize ();
293
+ threshold = threshold / (100.0 * n_d * trunc (n_d / 2.0 ));
294
+ }
295
+
286
296
if (test_contrast) {
287
297
double diff = 1e6 ;
288
298
for (unsigned int n = 0 ; n < ((2 * range) + 1 ); ++n) {
289
299
// convolution results
290
300
double convolution_ = list_query_pixels[n].convolution (I, me);
291
- double threshold = list_query_pixels[n].getContrastThreshold ();
292
-
293
- if (me->getLikelihoodThresholdType () == vpMe::NORMALIZED_THRESHOLD) {
294
- threshold = 2.0 * threshold;
295
- }
296
- else {
297
- double n_d = me->getMaskSize ();
298
- threshold = threshold / (100.0 * n_d * trunc (n_d / 2.0 ));
299
- }
300
-
301
301
// luminance ratio of reference pixel to potential correspondent pixel
302
302
// the luminance must be similar, hence the ratio value should
303
303
// lay between, for instance, 0.5 and 1.5 (parameter tolerance)
@@ -316,15 +316,6 @@ void vpMeSite::track(const vpImage<unsigned char> &I, const vpMe *me, const bool
316
316
}
317
317
else { // test on contrast only
318
318
for (unsigned int n = 0 ; n < ((2 * range) + 1 ); ++n) {
319
- double threshold = list_query_pixels[n].getContrastThreshold ();
320
-
321
- if (me->getLikelihoodThresholdType () == vpMe::NORMALIZED_THRESHOLD) {
322
- threshold = 2.0 * threshold;
323
- }
324
- else {
325
- double n_d = me->getMaskSize ();
326
- threshold = threshold / (100.0 * n_d * trunc (n_d / 2.0 ));
327
- }
328
319
329
320
// convolution results
330
321
double convolution_ = list_query_pixels[n].convolution (I, me);
0 commit comments