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

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

#include <TemplateMatching.h>

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

List of all members.

Public Member Functions

 TemplateMatchingInRows ()
 ~TemplateMatchingInRows ()

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 row.

Definition at line 382 of file TemplateMatching.h.


Constructor & Destructor Documentation

Definition at line 391 of file TemplateMatching.h.

{}

Definition at line 392 of file TemplateMatching.h.

{}

Member Function Documentation

bool TemplateMatchingInRows::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::TemplateMatchingAlongGrid.

Definition at line 772 of file TemplateMatching.cc.

References debug(), degate::BoundingBox::get_height(), degate::BoundingBox::get_max_y(), 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 &&
     initialize_state_struct(state,
                             state->search_area.get_min_y(),
                             state->search_area.get_max_y() - tmpl_h,
                             false) == false) {
    debug(TM, "Can't initialize search structure.");
    return false;
  }


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

  bool there_was_a_gate = false;

  do {

    if(state->x + step < state->search_area.get_width() - tmpl_w)
      state->x += step;
    else {
      ++(state->iter);

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

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

    }

    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: