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

This class implements matching for gate template that are aligned in a column. More...

#include <TemplateMatching.h>

Inheritance diagram for degate::TemplateMatchingInCols:
Inheritance graph

List of all members.

Public Member Functions

 TemplateMatchingInCols ()
 ~TemplateMatchingInCols ()

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 matching for gate template that are aligned in a column.

Definition at line 400 of file TemplateMatching.h.

Constructor & Destructor Documentation

Definition at line 408 of file TemplateMatching.h.


Definition at line 409 of file TemplateMatching.h.


Member Function Documentation

bool TemplateMatchingInCols::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 false if there is no further position.

Implements degate::TemplateMatchingAlongGrid.

Definition at line 841 of file

References debug(), degate::BoundingBox::get_height(), degate::BoundingBox::get_max_x(), degate::BoundingBox::get_min_x(), degate::BoundingBox::get_min_y(), degate::BoundingBox::get_width(), degate::TemplateMatching::search_state::grid, degate::TemplateMatchingAlongGrid::initialize_state_struct(), degate::TemplateMatching::search_state::iter, degate::TemplateMatching::search_state::iter_end, degate::TemplateMatching::search_state::iter_last, degate::TemplateMatching::layer_insert, degate::TemplateMatching::search_state::search_area, degate::TemplateMatching::search_state::step_size_search, TM, degate::TemplateMatching::prepared_template::tmpl_img_normal, degate::TemplateMatching::search_state::x, and degate::TemplateMatching::search_state::y.


  // check if the search area is larger then the template
  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;

  // get grid and check if we are working on regular or irregular grid
  if(state->grid == NULL &&
                             state->search_area.get_max_x() - tmpl_w,
                             true) == false)
    return false;

  if(state->x == 1 && state->y == 1) { // start condition
    state->x = *(state->iter) - state->search_area.get_min_x();

  bool there_was_a_gate = false;

  do {
    if(state->y + step < state->search_area.get_height() - tmpl_h)
      state->y += step;
    else {

      if(state->iter == state->iter_end ||
         *(state->iter) > *(state->iter_last)) return false;

      state->x = *(state->iter) - state->search_area.get_min_x();
      state->y = 1;


    unsigned int dist_y = layer_insert->get_distance_to_gate_boundary(state->x + state->search_area.get_min_x(),
                                                                      state->y + state->search_area.get_min_y(),
                                                                      false, tmpl_w, tmpl_h);

    if(dist_y > 0) {
      debug(TM, "In the window starting at %d,%d there is already a gate. Skipping %d vertical pixels",
            state->x + state->search_area.get_min_x(),
            state->y + state->search_area.get_min_y(),
      state->y += dist_y;
      there_was_a_gate = true;
      step = 1;
    else there_was_a_gate = false;


  return true;

Here is the call graph for this function:

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