34 #include <visp3/core/vpConfig.h>
35 #include <visp3/core/vpDisplay.h>
36 #include <visp3/blob/vpDot2.h>
45 void vpDot2::searchDotsAreaGoodGerm(vpSearchDotsInAreaGoodGermData &data)
48 unsigned int border_u;
49 unsigned int border_v;
50 bool good_germ =
true;
51 std::list<vpDot2>::iterator itbad;
52 std::list<vpDot2>::iterator itnice;
53 vpDot2 *dotToTest =
nullptr;
56 if (findFirstBorder(data.m_I, data.m_u, data.m_v, border_u, border_v) ==
false) {
64 itbad = data.m_badDotsVector.begin();
67 while ((itbad != data.m_badDotsVector.end()) && (good_germ ==
true)) {
68 if ((
static_cast<double>(data.m_u) >= (*itbad).m_bbox_u_min) && (
static_cast<double>(data.m_u) <= (*itbad).m_bbox_u_max) &&
69 (
static_cast<double>(data.m_v) >= (*itbad).m_bbox_v_min) && (
static_cast<double>(data.m_v) <= (*itbad).m_bbox_v_max)) {
70 std::list<vpImagePoint>::const_iterator it_edges = m_ip_edges_list.begin();
71 while ((it_edges != m_ip_edges_list.end()) && (good_germ ==
true)) {
75 cogBadDot = *it_edges;
76 if ((std::fabs(border_u - cogBadDot.
get_u()) <=
78 std::numeric_limits<double>::epsilon())) &&
79 (std::fabs(data.m_v - cogBadDot.
get_v()) <=
81 std::numeric_limits<double>::epsilon()))) {
103 if (dotToTest !=
nullptr) {
106 dotToTest = getInstance();
122 if (dotToTest->computeParameters(data.m_I) ==
false) {
130 if (dotToTest->isValid(data.m_I, *
this)) {
137 double area_center_u = (data.m_area.getLeft() + (data.m_area.getWidth() / 2.0)) - 0.5;
138 double area_center_v = (data.m_area.getTop() + (data.m_area.getHeight() / 2.0)) - 0.5;
140 double thisDiff_u = cogDotToTest.
get_u() - area_center_u;
141 double thisDiff_v = cogDotToTest.
get_v() - area_center_v;
142 double thisDist = sqrt((thisDiff_u * thisDiff_u) + (thisDiff_v * thisDiff_v));
144 bool stopLoop =
false;
145 itnice = data.m_niceDots.begin();
147 while ((itnice != data.m_niceDots.end()) && (stopLoop ==
false)) {
151 double epsilon = 3.0;
154 cogTmpDot = tmpDot.
getCog();
156 if ((fabs(cogTmpDot.
get_u() - cogDotToTest.
get_u()) < epsilon) &&
157 (fabs(cogTmpDot.
get_v() - cogDotToTest.
get_v()) < epsilon)) {
165 double otherDiff_u = cogTmpDot.
get_u() - area_center_u;
166 double otherDiff_v = cogTmpDot.
get_v() - area_center_v;
167 double otherDist = sqrt((otherDiff_u * otherDiff_u) + (otherDiff_v * otherDiff_v));
172 if (otherDist > thisDist) {
173 data.m_niceDots.insert(itnice, *dotToTest);
186 if ((itnice == data.m_niceDots.end()) && (stopLoop ==
false)) {
187 data.m_niceDots.push_back(*dotToTest);
192 data.m_badDotsVector.push_front(*dotToTest);
197 if (dotToTest !=
nullptr) {
225 unsigned int area_h, std::list<vpDot2> &niceDots)
233 setArea(I, area_u, area_v, area_w, area_h);
236 unsigned int gridWidth;
237 unsigned int gridHeight;
238 getGridSize(gridWidth, gridHeight);
252 std::list<vpDot2> badDotsVector;
253 std::list<vpDot2>::iterator itnice;
257 unsigned int area_u_min =
static_cast<unsigned int>(m_area.
getLeft());
258 unsigned int area_u_max =
static_cast<unsigned int>(m_area.
getRight());
259 unsigned int area_v_min =
static_cast<unsigned int>(m_area.
getTop());
260 unsigned int area_v_max =
static_cast<unsigned int>(m_area.
getBottom());
266 while (v < area_v_max) {
268 while (u < area_u_max) {
272 if (hasGoodLevel(I, u, v)) {
276 bool good_germ =
true;
278 itnice = niceDots.begin();
279 while ((itnice != niceDots.end()) && (good_germ ==
true)) {
282 cogTmpDot = tmpDot.
getCog();
283 double u0 = cogTmpDot.
get_u();
284 double v0 = cogTmpDot.
get_v();
285 double half_w = tmpDot.
getWidth() / 2.;
288 if ((u >= (u0 - half_w)) && (u <= (u0 + half_w)) && (v >= (v0 - half_h)) && (v <= (v0 + half_h))) {
296 vpRect area(area_u, area_v, area_w, area_h);
297 vpSearchDotsInAreaGoodGermData data(I, area, u, v, niceDots, badDotsVector);
298 searchDotsAreaGoodGerm(data);
static const vpColor blue
static void flush(const vpImage< unsigned char > &I)
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
unsigned int getGrayLevelMin() const
unsigned int getGrayLevelMax() const
void setGraphics(bool activate)
void setGraphicsThickness(unsigned int thickness)
void searchDotsInArea(const vpImage< unsigned char > &I, int area_u, int area_v, unsigned int area_w, unsigned int area_h, std::list< vpDot2 > &niceDots)
void setGrayLevelMax(const unsigned int &max)
void setSizePrecision(const double &sizePrecision)
void setGrayLevelPrecision(const double &grayLevelPrecision)
void setGrayLevelMin(const unsigned int &min)
void setCog(const vpImagePoint &ip)
vpImagePoint getCog() const
double getSizePrecision() const
double getGrayLevelPrecision() const
void setEllipsoidBadPointsPercentage(const double &percentage=0.0)
void setEllipsoidShapePrecision(const double &ellipsoidShapePrecision)
void setArea(const double &area)
void setComputeMoments(bool activate)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static Type maximum(const Type &a, const Type &b)
Defines a rectangle in the plane.