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

This class is the base class for template matching along a grid. More...

#include <TemplateMatching.h>

Inheritance diagram for degate::TemplateMatchingAlongGrid:
Inheritance graph

List of all members.

Public Member Functions

virtual ~TemplateMatchingAlongGrid ()

Protected Member Functions

bool initialize_state_struct (struct search_state *state, int offs_min, int offs_max, bool is_horizontal_grid) const
virtual bool get_next_pos (struct search_state *state, struct prepared_template const &tmpl) const =0
 Calculate the next position for a template to background matching.

Detailed Description

This class is the base class for template matching along a grid.

Definition at line 360 of file TemplateMatching.h.

Constructor & Destructor Documentation

Definition at line 374 of file TemplateMatching.h.


Member Function Documentation

virtual bool degate::TemplateMatchingAlongGrid::get_next_pos ( struct search_state state,
struct prepared_template const &  tmpl 
) const [protected, pure virtual]

Calculate the next position for a template to background matching.

Returns false if there is no further position.

Implements degate::TemplateMatching.

Implemented in degate::TemplateMatchingInCols, and degate::TemplateMatchingInRows.

bool TemplateMatchingAlongGrid::initialize_state_struct ( struct search_state state,
int  offs_min,
int  offs_max,
bool  is_horizontal_grid 
) const [protected]

Definition at line 717 of file

References debug(), degate::TemplateMatching::search_state::grid, degate::TemplateMatching::search_state::iter, degate::TemplateMatching::search_state::iter_begin, degate::TemplateMatching::search_state::iter_end, degate::TemplateMatching::search_state::iter_last, degate::TemplateMatching::project, and TM.

Referenced by degate::TemplateMatchingInRows::get_next_pos(), and degate::TemplateMatchingInCols::get_next_pos().

  if(state->grid == NULL) {
    const RegularGrid_shptr rg = is_horizontal_grid ?
      project->get_regular_horizontal_grid() : project->get_regular_vertical_grid();
    const IrregularGrid_shptr ig = is_horizontal_grid ?
      project->get_irregular_horizontal_grid() : project->get_irregular_vertical_grid();

    if(rg->is_enabled()) state->grid = rg;
    else if(ig->is_enabled()) state->grid = ig;

    if(state->grid != NULL) {

      debug(TM, "check grid from %d to %d", offs_min, offs_max);

      // iterate over grid and find first and last offset
      state->iter_begin = state->grid->begin();
      state->iter_last = state->grid->begin();
      state->iter_end = state->grid->end();

      for(Grid::grid_iter iter = state->grid->begin();
          iter != state->grid->end(); ++iter) {
        debug(TM, "\tcheck %d", *iter);
        if(*iter < offs_min) state->iter_begin = iter;
        if(*iter < offs_max) state->iter_last = iter;

      if(*(state->iter_begin) < offs_min &&
         state->iter_begin != state->grid->end()) state->iter_begin++;

      //if(state->iter_last != state->grid->end()) state->iter_last++;

      if(state->iter_begin != state->grid->end())
        debug(TM, "first grid offset %d", *(state->iter_begin) );
      //      if(state->iter_last != state->grid->end())
      debug(TM, "last  grid offset %d", *(state->iter_last));

      if(state->iter_begin == state->grid->end() ||
         state->iter_last == state->grid->end()) {
        debug(TM, "failed");
        return false;

      state->iter = state->iter_begin;
    else {
      debug(TM, "There is no grid enabled.");
      return false;
  return true;

Here is the call graph for this function:

Here is the caller graph for this function:

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