Skip to content

Commit 11f8548

Browse files
committed
start work on refactoring vpMeSite
1 parent 7b7c6cf commit 11f8548

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

modules/tracker/me/src/moving-edges/vpMeSite.cpp

+10-19
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,21 @@ void vpMeSite::track(const vpImage<unsigned char> &I, const vpMe *me, const bool
283283
// array in which likelihood ratios will be stored
284284
double *likelihood = new double[(2 * range) + 1];
285285

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+
286296
if (test_contrast) {
287297
double diff = 1e6;
288298
for (unsigned int n = 0; n < ((2 * range) + 1); ++n) {
289299
// convolution results
290300
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-
301301
// luminance ratio of reference pixel to potential correspondent pixel
302302
// the luminance must be similar, hence the ratio value should
303303
// 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
316316
}
317317
else { // test on contrast only
318318
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-
}
328319

329320
// convolution results
330321
double convolution_ = list_query_pixels[n].convolution(I, me);

0 commit comments

Comments
 (0)