From 7a977b5568b5870c71a411fcf16311ecdaf779f2 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 15 Jun 2016 23:33:22 +0200 Subject: [PATCH] Reduce step size in DS search. * Reduce DS step size instead of switching to smaller pattern. * Makes it slower but more accurate, close to EX search. --- src/omv/img/template.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/omv/img/template.c b/src/omv/img/template.c index 8e505b4fe..7a670ac7e 100644 --- a/src/omv/img/template.c +++ b/src/omv/img/template.c @@ -91,11 +91,11 @@ static float find_block_ncc(image_t *f, image_t *t, i_image_t *sum, int t_mean, v = 0; } - if (u+t->w > f->w) { + if (u+t->w >= f->w) { w = f->w - u; } - if (v+t->h > f->h) { + if (v+t->h >= f->h) { h = f->h - v; } @@ -147,13 +147,17 @@ float imlib_template_match_ds(image_t *f, image_t *t, rectangle_t *r) // Start with the Large Diamond Search Pattern (LDSP) 9 points. bool sdsp = false; - while (true) { + // Step size == template width + int step = t->w; + while (step) { + //while (true) { // Set the Diamond Search Pattern (DSP). - set_dsp(cx, cy, pts, sdsp, t->w); + set_dsp(cx, cy, pts, sdsp, step); // Set the number of search blocks (5 or 9 for SDSP and LDSP respectively). int num_pts = (sdsp == true)? 5: 9; + // Find the block with the highest NCC for (int i=0; ix = cx;