degate  0.1.2
Public Member Functions | Protected Member Functions
degate::TemplateMatchingNormal Class Reference

This class implements a template matching that basically scans line by line to detect gate placements. More...

#include <TemplateMatching.h>

Inheritance diagram for degate::TemplateMatchingNormal:
Inheritance graph
[legend]

List of all members.

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.

Detailed Description

This class implements a template matching that basically scans line by line to detect gate placements.

Definition at line 344 of file TemplateMatching.h.


Constructor & Destructor Documentation

Definition at line 349 of file TemplateMatching.h.

{}

Definition at line 350 of file TemplateMatching.h.

{}

Member Function Documentation

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.

Returns:
Returns false if there is no further position.

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;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files: