|
degate 0.1.1
|
This class implements a template matching that basically scans line by line to detect gate placements. More...
#include <TemplateMatching.h>

Public Member Functions | |
| TemplateMatchingNormal () | |
| ~TemplateMatchingNormal () | |
Protected Member Functions | |
| bool | get_next_pos (struct search_state *state, struct prepared_template const &tmpl) const |
| Calculate the next position for a template to background matching. | |
This class implements a template matching that basically scans line by line to detect gate placements.
Definition at line 344 of file TemplateMatching.h.
| degate::TemplateMatchingNormal::TemplateMatchingNormal | ( | ) | [inline] |
Definition at line 349 of file TemplateMatching.h.
{}
| degate::TemplateMatchingNormal::~TemplateMatchingNormal | ( | ) | [inline] |
Definition at line 350 of file TemplateMatching.h.
{}
| bool TemplateMatchingNormal::get_next_pos | ( | struct search_state * | state, |
| struct prepared_template const & | tmpl | ||
| ) | const [protected, virtual] |
Calculate the next position for a template to background matching.
Implements degate::TemplateMatching.
Definition at line 669 of file TemplateMatching.cc.
References degate::BoundingBox::get_height(), degate::BoundingBox::get_min_x(), degate::BoundingBox::get_min_y(), degate::BoundingBox::get_width(), degate::TemplateMatching::layer_insert, degate::TemplateMatching::search_state::search_area, degate::TemplateMatching::search_state::step_size_search, degate::TemplateMatching::prepared_template::tmpl_img_normal, degate::TemplateMatching::search_state::x, and degate::TemplateMatching::search_state::y.
{
unsigned int
tmpl_w = tmpl.tmpl_img_normal->get_width(),
tmpl_h = tmpl.tmpl_img_normal->get_height();
if(state->search_area.get_width() < tmpl_w ||
state->search_area.get_height() < tmpl_h) return false;
unsigned int step = state->step_size_search;
bool there_was_a_gate = false;
do {
if(state->x + step < state->search_area.get_width() - tmpl_w)
state->x += step;
else {
state->x = 1;
if(state->y + step < state->search_area.get_height() - tmpl_h)
state->y += step;
else return false;
}
unsigned int dist_x =
layer_insert->get_distance_to_gate_boundary(state->x + state->search_area.get_min_x(),
state->y + state->search_area.get_min_y(),
true, tmpl_w, tmpl_h);
if(dist_x > 0) {
/*
debug(TM, "In the window starting at %d,%d there is already a gate. Skipping %d horizontal pixels",
state->x + state->search_area.get_min_x(),
state->y + state->search_area.get_min_y(),
dist_x);
*/
state->x += dist_x;
there_was_a_gate = true;
step = 1;
}
else there_was_a_gate = false;
}while(there_was_a_gate);
return true;
}

1.7.4