Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpDot.h
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Track a white dot.
32
*/
33
38
39
#ifndef VP_DOT_H
40
#define VP_DOT_H
41
42
#include <visp3/core/vpConfig.h>
43
#include <visp3/core/vpDisplay.h>
44
#include <visp3/core/vpImage.h>
45
#include <visp3/core/vpImagePoint.h>
46
#include <visp3/core/vpPolygon.h>
47
#include <visp3/core/vpRect.h>
48
#include <visp3/core/vpTracker.h>
49
50
#include <fstream>
51
#include <list>
52
#include <math.h>
53
#include <vector>
54
55
#ifdef VISP_USE_MSVC
56
#pragma comment(linker, "/STACK:256000000")
// Increase max recursion depth
57
#endif
58
59
BEGIN_VISP_NAMESPACE
60
122
class
VISP_EXPORT
vpDot
:
public
vpTracker
123
{
124
public
:
128
typedef
enum
129
{
130
CONNEXITY_4
,
132
CONNEXITY_8
134
} vpConnexityType;
135
136
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
137
public
:
138
static
const
unsigned
int
SPIRAL_SEARCH_SIZE
;
139
140
double
m00
;
147
double
m01
;
154
double
m10
;
161
double
m11
;
168
double
m20
;
175
double
m02
;
182
double
mu11
;
187
double
mu20
;
192
double
mu02
;
197
#endif
198
199
public
:
200
vpDot
();
201
VP_EXPLICIT
vpDot
(
const
vpImagePoint
&ip);
202
vpDot
(
const
vpDot
&d);
203
virtual
~vpDot
() VP_OVERRIDE;
204
205
void
display
(const
vpImage
<
unsigned
char
> &I,
vpColor
color =
vpColor
::red,
unsigned
int
thickness = 1) const;
206
216
inline
vpColVector
get_nij
()
const
217
{
218
vpColVector
nij(3);
219
const
unsigned
int
index_0 = 0;
220
const
unsigned
int
index_1 = 1;
221
const
unsigned
int
index_2 = 2;
222
nij[index_0] =
mu20
/
m00
;
223
nij[index_1] =
mu11
/
m00
;
224
nij[index_2] =
mu02
/
m00
;
225
226
return
nij;
227
}
228
234
inline
double
getArea
()
const
{
return
m00
; }
235
241
inline
vpRect
getBBox
()
const
242
{
243
vpRect
bbox;
244
245
bbox.
setRect
(m_u_min, m_v_min, (m_u_max - m_u_min) + 1, (m_v_max - m_v_min) + 1);
246
247
return
bbox;
248
}
249
255
inline
vpImagePoint
getCog
()
const
{
return
m_cog; }
256
263
inline
std::list<vpImagePoint>
getEdges
()
const
{
return
m_ip_edges_list; }
264
271
inline
std::list<vpImagePoint>
getConnexities
()
const
{
return
m_ip_connexities_list; }
272
273
inline
double
getGamma
()
const
{
return
m_gamma; }
274
280
double
getGrayLevelPrecision
()
const
{
return
m_grayLevelPrecision; }
281
double
getMaxDotSize
()
const
{
return
m_maxDotSizePercentage; }
282
286
double
getMeanGrayLevel
()
const
{
return
m_mean_gray_level; }
287
291
vpPolygon
getPolygon
()
const
{
return
(
vpPolygon
(m_ip_edges_list)); }
292
298
inline
unsigned
int
getWidth
()
const
{
return
((m_u_max - m_u_min) + 1); }
299
305
inline
unsigned
int
getHeight
()
const
{
return
((m_v_max - m_v_min) + 1); }
306
307
void
initTracking(
const
vpImage<unsigned char>
&I);
308
void
initTracking(
const
vpImage<unsigned char>
&I,
const
vpImagePoint
&ip);
309
void
initTracking(
const
vpImage<unsigned char>
&I,
const
vpImagePoint
&ip,
unsigned
int
gray_level_min,
310
unsigned
int
gray_level_max);
311
312
vpDot
&
operator=
(
const
vpDot
&d);
313
bool
operator==(
const
vpDot
&d)
const
;
314
bool
operator!=(
const
vpDot
&d)
const
;
315
friend
VISP_EXPORT std::ostream &operator<<(std::ostream &os,
vpDot
&d);
316
317
void
print
(std::ostream &os) { os << *
this
<< std::endl; }
318
322
inline
void
setCog
(
const
vpImagePoint
&cog) { m_cog = cog; }
323
337
void
setComputeMoments
(
bool
activate) { m_compute_moment = activate; }
338
342
void
setConnexity
(
const
vpConnexityType
&connexityType) { m_connexityType = connexityType; }
343
void
setMaxDotSize(
double
percentage);
344
void
setGrayLevelMin
(
const
unsigned
int
&level_min) { m_gray_level_min = level_min; }
345
void
setGrayLevelMax
(
const
unsigned
int
&level_max) { m_gray_level_max = level_max; }
346
void
setGrayLevelPrecision(
const
double
&grayLevelPrecision);
347
361
362
void
setGraphics
(
bool
activate) { m_graphics = activate; }
369
void
setGraphicsThickness
(
unsigned
int
thickness) { m_thickness = thickness; }
370
371
void
track(
const
vpImage<unsigned char>
&I);
372
void
track(
const
vpImage<unsigned char>
&I,
vpImagePoint
&ip);
373
374
// Static Functions
375
public
:
376
static
void
display(
const
vpImage<unsigned char>
&I,
const
vpImagePoint
&cog,
377
const
std::list<vpImagePoint> &edges_list,
vpColor
color =
vpColor::red
,
378
unsigned
int
thickness = 1);
379
static
void
display(
const
vpImage<vpRGBa>
&I,
const
vpImagePoint
&cog,
const
std::list<vpImagePoint> &edges_list,
380
vpColor
color =
vpColor::red
,
unsigned
int
thickness = 1);
381
382
#ifndef VISP_BUILD_DEPRECATED_FUNCTIONS
383
private
:
384
static
const
unsigned
int
SPIRAL_SEARCH_SIZE;
385
386
double
m00;
393
double
m01;
400
double
m10;
407
double
m11;
414
double
m20;
421
double
m02;
428
double
mu11;
433
double
mu20;
438
double
mu02;
443
#endif
444
445
private
:
447
std::list<vpImagePoint> m_ip_connexities_list;
448
450
std::list<vpImagePoint> m_ip_edges_list;
451
456
vpConnexityType m_connexityType;
457
459
vpImagePoint
m_cog;
460
461
// Bounding box
462
unsigned
int
m_u_min, m_u_max, m_v_min, m_v_max;
463
464
// Flag used to allow display
465
bool
m_graphics;
466
467
unsigned
int
m_thickness;
// Graphics thickness
468
469
double
m_maxDotSizePercentage;
470
unsigned
char
m_gray_level_out;
471
472
double
m_mean_gray_level;
// Mean gray level of the dot
473
unsigned
int
m_gray_level_min;
// left threshold for binarization
474
unsigned
int
m_gray_level_max;
// right threshold for binarization
475
double
m_grayLevelPrecision;
// precision of the gray level of the dot.
476
// It is a double precision float witch value is in ]0,1].
477
// 1 means full precision, whereas values close to 0 show a very bad
478
// precision
479
double
m_gamma;
481
bool
m_compute_moment;
482
double
m_nbMaxPoint;
483
484
void
init
();
485
void
setGrayLevelOut();
486
bool
connexe(
const
vpImage<unsigned char>
&I,
unsigned
int
u,
unsigned
int
v,
double
&mean_value,
487
vpImagePoint
&uv_cog,
unsigned
int
&npoints);
488
bool
connexe(
const
vpImage<unsigned char>
&I,
unsigned
int
u,
unsigned
int
v,
double
&mean_value,
489
vpImagePoint
&uv_cog,
unsigned
int
&npoints, std::vector<bool> &checkTab);
490
void
COG(
const
vpImage<unsigned char>
&I,
double
&u,
double
&v);
491
};
492
493
END_VISP_NAMESPACE
494
#endif
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpColor
Class to define RGB colors available for display functionalities.
Definition
vpColor.h:157
vpColor::red
static const vpColor red
Definition
vpColor.h:198
vpDot
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition
vpDot.h:123
vpDot::mu02
double mu02
Definition
vpDot.h:192
vpDot::display
void display(const vpImage< unsigned char > &I, vpColor color=vpColor::red, unsigned int thickness=1) const
Definition
vpDot.cpp:813
vpDot::getEdges
std::list< vpImagePoint > getEdges() const
Definition
vpDot.h:263
vpDot::getBBox
vpRect getBBox() const
Definition
vpDot.h:241
vpDot::m10
double m10
Definition
vpDot.h:154
vpDot::getConnexities
std::list< vpImagePoint > getConnexities() const
Definition
vpDot.h:271
vpDot::getWidth
unsigned int getWidth() const
Definition
vpDot.h:298
vpDot::mu11
double mu11
Definition
vpDot.h:182
vpDot::m01
double m01
Definition
vpDot.h:147
vpDot::setGraphics
void setGraphics(bool activate)
Definition
vpDot.h:362
vpDot::vpDot
vpDot()
Definition
vpDot.cpp:100
vpDot::setConnexity
void setConnexity(const vpConnexityType &connexityType)
Definition
vpDot.h:342
vpDot::getArea
double getArea() const
Definition
vpDot.h:234
vpDot::getMeanGrayLevel
double getMeanGrayLevel() const
Definition
vpDot.h:286
vpDot::mu20
double mu20
Definition
vpDot.h:187
vpDot::setCog
void setCog(const vpImagePoint &cog)
Definition
vpDot.h:322
vpDot::m11
double m11
Definition
vpDot.h:161
vpDot::setGraphicsThickness
void setGraphicsThickness(unsigned int thickness)
Definition
vpDot.h:369
vpDot::SPIRAL_SEARCH_SIZE
static const unsigned int SPIRAL_SEARCH_SIZE
Definition
vpDot.h:138
vpDot::m02
double m02
Definition
vpDot.h:175
vpDot::getMaxDotSize
double getMaxDotSize() const
Definition
vpDot.h:281
vpDot::print
void print(std::ostream &os)
Definition
vpDot.h:317
vpDot::getPolygon
vpPolygon getPolygon() const
Definition
vpDot.h:291
vpDot::setGrayLevelMax
void setGrayLevelMax(const unsigned int &level_max)
Definition
vpDot.h:345
vpDot::setGrayLevelMin
void setGrayLevelMin(const unsigned int &level_min)
Definition
vpDot.h:344
vpDot::setComputeMoments
void setComputeMoments(bool activate)
Definition
vpDot.h:337
vpDot::getGrayLevelPrecision
double getGrayLevelPrecision() const
Definition
vpDot.h:280
vpDot::m00
double m00
Definition
vpDot.h:140
vpDot::m20
double m20
Definition
vpDot.h:168
vpDot::get_nij
vpColVector get_nij() const
Definition
vpDot.h:216
vpDot::vpConnexityType
vpConnexityType
Definition
vpDot.h:129
vpDot::CONNEXITY_8
@ CONNEXITY_8
Definition
vpDot.h:132
vpDot::CONNEXITY_4
@ CONNEXITY_4
Definition
vpDot.h:130
vpDot::getGamma
double getGamma() const
Definition
vpDot.h:273
vpDot::getCog
vpImagePoint getCog() const
Definition
vpDot.h:255
vpDot::getHeight
unsigned int getHeight() const
Definition
vpDot.h:305
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpPolygon
Defines a generic 2D polygon.
Definition
vpPolygon.h:103
vpRect
Defines a rectangle in the plane.
Definition
vpRect.h:79
vpRect::setRect
void setRect(double l, double t, double w, double h)
Definition
vpRect.h:333
vpTracker::operator=
vpTracker & operator=(const vpTracker &tracker)
Copy operator.
Definition
vpTracker.cpp:49
vpTracker::init
void init()
Default initialization.
Definition
vpTracker.cpp:43
vpTracker::vpTracker
vpTracker()
Default constructor.
Definition
vpTracker.cpp:45
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
tracker
blob
include
visp3
blob
vpDot.h
Generated by
1.17.0