Jafar
|
Active search tesselation grid. More...
Active search tesselation grid.
This class implements a tesselation grid for achieving active search behavior in landmark initialization.
The grid defines a set of cells in the image. The idea is to count the number of projected landmarks per grid cell, and use one randomly chosen cell that is empty for feature detection and landmark initialization. This guarantees that the system will automatically populate all the regions of the image.
The feature density can be controlled by adjusting the grid's number of cells. Typically, use grids of 5x5 to 9x9 cells.
This class implements a few interesting features:
The blue and green grids in the figure below represent the grid at two different offsets, corresponding to two different frames.
This second figure shows a typical situation that we use to explain the basic mechanism.
Observe the figure and use the following facts as an operation guide:
We include here a schematic active-search pseudo-code algorithm to illustrate its operation:
// Init necessary objects ActiveSearch activeSearch; ActiveSearchGrid grid(640, 480, 4, 4, 10); // Construction with 10 pixels separation. // We start projecting everybody for (obs = begin(); obs != end(); obs++) // loop observations { obs->project(); if (obs->isVisible()) grid.addObs(obs->expectation.x()); // add only visible landmarks } // Then we process the selected observations activeSearch.selectObs(); // select interesting features for (activeSearch.selectedObs); // loop selected obs obs.process(); // process observation // Now we go to initialization grid.getRoi(roi); // roi is now region of interest if (detectFeature(roi)) // detect inside ROI initLandmark(); // initialize only if successful detection
Definition at line 109 of file activeSearch.hpp.
#include <activeSearch.hpp>
Public Types | |
typedef std::vector < std::vector < observation_ptr_t > > | Grid |
Public Member Functions | |
ActiveSearchGrid (const int &imgSize_h, const int &imgSize_v, const int &nCells_h, const int &nCells_v, const int &margin=0, const int &separation=0) | |
Constructor. | |
void | clear () |
Clear grid. | |
void | renew () |
Clear grid and position it at a new random location. | |
void | addObs (const vec2 &pix, observation_ptr_t obsPtr) |
Add a projected pixel to the grid. | |
bool | getRoi (image::ConvexRoi &roi) |
Get ROI of a random empty cell. | |
void | setFailed (const image::ConvexRoi &roi) |
Call this after getRoi if no point was found in the roi in order to avoid searching again in it. | |
Public Attributes | |
Grid | projections |
Private Member Functions | |
template<class Vec2 > | |
veci2 | pix2cell (const Vec2 &pix) |
Get cell corresponding to pixel. | |
veci2 | cellOrigin (const veci2 &cell) |
Get cell origin (exact pixel) | |
vec2 | cellCenter (const veci2 &cell) |
Get cell center (can be decimal if size of cell is an odd number of pixels) | |
bool | pickEmptyCell (veci2 &cell) |
Get one random empty cell. | |
void | cell2roi (const veci2 &cell, image::ConvexRoi &roi) |
Get the region of interest, reduced by a margin. | |
Private Attributes | |
veci2 | imgSize |
veci2 | gridSize |
veci2 | cellSize |
veci2 | offset |
mati | projectionsCount |
mati | emptyCellsTile_tmp |
int | separation |
int | margin |
int | cells_h |
Friends | |
std::ostream & | operator<< (std::ostream &s, ActiveSearchGrid const &grid) |
jafar::rtslam::ActiveSearchGrid::ActiveSearchGrid | ( | const int & | imgSize_h, |
const int & | imgSize_v, | ||
const int & | nCells_h, | ||
const int & | nCells_v, | ||
const int & | margin = 0 , |
||
const int & | separation = 0 |
||
) |
Constructor.
imgSize_h | horizontal image size, in pixels. |
imgSize_v | vertical image size. |
nCells_h | horizontal number of cells per image width. |
nCells_v | vertical number of cells per image height. |
separation | minimum separation between existing and new points. |
void jafar::rtslam::ActiveSearchGrid::addObs | ( | const vec2 & | pix, |
observation_ptr_t | obsPtr | ||
) |
Add a projected pixel to the grid.
pix | the pixel to add. |
Clear grid.
Sets all cell counters to zero.
bool jafar::rtslam::ActiveSearchGrid::getRoi | ( | image::ConvexRoi & | roi | ) |
Get ROI of a random empty cell.
roi | the resulting ROI |
Clear grid and position it at a new random location.
Sets all cell counters to zero and sets a new random grid position.
void jafar::rtslam::ActiveSearchGrid::setFailed | ( | const image::ConvexRoi & | roi | ) |
Call this after getRoi if no point was found in the roi in order to avoid searching again in it.
roi | the ROI where nothing was found |
Generated on Wed Oct 15 2014 00:37:44 for Jafar by doxygen 1.7.6.1 |