39 #include <visp3/core/vpColor.h>
40 #include <visp3/core/vpDisplay.h>
41 #include <visp3/me/vpMeTracker.h>
44 #include <visp3/core/vpTrackingException.h>
51 const unsigned int val_2 = 2;
57 : m_meList(), m_me(nullptr), m_init_range(1), m_nGoodElement(0), m_mask(nullptr), m_maskCandidates(nullptr), m_selectDisplay(
vpMeSite::NONE)
63 :
vpTracker(meTracker), m_meList(), m_me(nullptr), m_init_range(1), m_nGoodElement(0), m_mask(nullptr), m_maskCandidates(nullptr), m_selectDisplay(
vpMeSite::NONE)
96 unsigned int number_signal = 0;
99 number_signal =
static_cast<unsigned int>(std::count_if(
m_meList.begin(),
m_meList.end(), isSuppressZero));
100 return number_signal;
108 return ((mask ==
nullptr) || (mask->
getValue(i, j)));
117 if (meMaskCandidates ==
nullptr) {
121 const unsigned int kernelSize = 3;
122 const unsigned int halfKernelSize = (kernelSize - 1) / 2;
123 const unsigned int nbRows = meMaskCandidates->
getRows();
124 const unsigned int nbCols = meMaskCandidates->
getCols();
126 if ((i >= nbRows) || (j >= nbCols)) {
130 if ((*meMaskCandidates)[i][j]) {
134 unsigned int iStart = 0, jStart = 0;
135 unsigned int iStop = nbRows - 1, jStop = nbCols - 1;
137 if (i >= halfKernelSize) {
138 iStart = i - halfKernelSize;
140 if (j >= halfKernelSize) {
141 jStart = j - halfKernelSize;
143 if ((i + halfKernelSize) < nbRows) {
144 iStop = i + halfKernelSize;
146 if ((j + halfKernelSize) < nbCols) {
147 jStop = j + halfKernelSize;
150 bool isACandidate =
false;
151 unsigned int iter_i = iStart, iter_j = jStart;
153 while ((!isACandidate) && (iter_i <= iStop)) {
155 while ((!isACandidate) && (iter_j <= jStop)) {
156 isACandidate = (*meMaskCandidates)[iter_i][iter_j];
168 int borderWith2SparedPixels = border + 2;
169 return (!((i > borderWith2SparedPixels) && (i < (nrows - borderWith2SparedPixels))
170 && (j > borderWith2SparedPixels) && (j < (ncols - borderWith2SparedPixels))
176 const int borderPlus2 = border + 2;
179 return (!((i > borderPlus2) && (i < (nrows - borderPlus2)) && (j > borderPlus2) && (j < (ncols - borderPlus2))));
195 std::list<vpMeSite>::iterator end =
m_meList.end();
196 for (std::list<vpMeSite>::iterator it =
m_meList.begin(); it != end; ++it) {
228 std::list<vpMeSite>::iterator it =
m_meList.begin();
229 std::list<vpMeSite>::iterator end =
m_meList.end();
256 std::list<vpMeSite>::const_iterator end =
m_meList.end();
257 for (std::list<vpMeSite>::const_iterator it =
m_meList.begin(); it != end; ++it) {
265 std::list<vpMeSite>::const_iterator end =
m_meList.end();
266 for (std::list<vpMeSite>::const_iterator it =
m_meList.begin(); it != end; ++it) {
274 std::list<vpMeSite>::iterator end =
m_meList.end();
275 for (std::list<vpMeSite>::iterator it =
m_meList.begin(); it != end; ++it) {
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
error that can be emitted by ViSP classes.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Type getValue(unsigned int i, unsigned int j) const
unsigned int getCols() const
unsigned int getRows() const
static int round(double x)
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
@ OUTSIDE_ROI_MASK
Point is outside the region of interest mask, but retained in the ME list.
@ NO_SUPPRESSION
Point successfully tracked.
void display(const vpImage< unsigned char > &I) const
void setWeight(const double &weight)
vpMeSiteState getState() const
void track(const vpImage< unsigned char > &I, const vpMe *me, const bool &test_contrast=true)
void setState(const vpMeSiteState &flag)
Contains abstract elements for a Distance to Feature type feature.
void initTracking(const vpImage< unsigned char > &I)
const vpImage< bool > * m_mask
Mask used to disable tracking on a part of image.
unsigned int numberOfSignal()
vpMeSite::vpMeSiteDisplayType m_selectDisplay
Moving-edges display type.
void track(const vpImage< unsigned char > &I)
unsigned int m_init_range
Initial range.
unsigned int totalNumberOfSignal()
vpMe * m_me
Moving edges initialisation parameters.
vpMeTracker & operator=(vpMeTracker &meTracker)
static bool inRoiMask(const vpImage< bool > *mask, unsigned int i, unsigned int j)
void display(const vpImage< unsigned char > &I)
int m_nGoodElement
Number of good moving-edges that are tracked.
bool outOfImage(int i, int j, int border, int nrows, int ncols)
virtual ~vpMeTracker() VP_OVERRIDE
std::list< vpMeSite > m_meList
static bool inMeMaskCandidates(const vpImage< bool > *meMaskCandidates, unsigned int i, unsigned int j)
void setRange(const unsigned int &range)
unsigned int getRange() const
Class that defines what is a feature generic tracker.
void init()
Default initialization.
Error that can be emitted by the vpTracker class and its derivatives.
@ notEnoughPointError
Not enough point to track.
@ initializationError
Tracker initialization error.