Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
tutorial-draw-circle.cpp
1
2
#include <visp3/core/vpConfig.h>
3
#include <visp3/gui/vpDisplayFactory.h>
4
#include <visp3/core/vpImageCircle.h>
5
#include <visp3/core/vpImageDraw.h>
6
7
#ifdef ENABLE_VISP_NAMESPACE
8
using namespace
VISP_NAMESPACE_NAME
;
9
#endif
10
11
int
main()
12
{
13
#if defined(VISP_HAVE_DISPLAY)
14
vpImage<unsigned char>
I(2160, 3840, 128);
15
vpImage<vpRGBa>
I_rgb(2160, 3840,
vpColor
(0, 0, 0));
16
17
{
18
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
19
std::shared_ptr<vpDisplay>
d
=
vpDisplayFactory::createDisplay
(I, -1, -1,
""
,
vpDisplay::SCALE_AUTO
);
20
#else
21
vpDisplay
*
d
=
vpDisplayFactory::allocateDisplay
(I, -1, -1,
""
,
vpDisplay::SCALE_AUTO
);
22
#endif
23
24
vpDisplay::display
(I);
26
vpImageCircle
circle(
vpImagePoint
(I.getHeight()/3, I.getWidth()/3), I.getWidth()/10.f);
27
// Displays in overlay a red circle on the image
28
// i.e. does not modify I
29
vpDisplay::displayCircle
(I, circle,
vpColor::red
,
false
, 2);
31
vpDisplay::setTitle
(I,
"Display a red circle on gray level image overlay"
);
32
vpDisplay::flush
(I);
33
std::cout <<
"Result of displaying a red circle on a gray level image overlay..."
<< std::endl;
34
std::cout <<
"A click to continue..."
<< std::endl;
35
vpDisplay::getClick
(I);
36
38
vpImageCircle
circle2(
vpImagePoint
(I.getHeight()/3, 2*I.getWidth()/3), I.getWidth()/10.f);
39
// Draws a white circle on the image
40
// i.e. modifies I
41
vpImageDraw::drawCircle
(I, circle2, 255, 2);
43
vpDisplay::display
(I);
44
vpDisplay::setTitle
(I,
"Display circle by modifying a gray level image"
);
45
std::cout <<
"Result of displaying a circle by modifying a gray level image..."
<< std::endl;
46
std::cout <<
"A click to continue..."
<< std::endl;
47
vpDisplay::flush
(I);
48
vpDisplay::getClick
(I);
49
50
51
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
52
delete
d
;
53
#endif
54
}
55
56
{
58
vpImageCircle
circle3(
vpImagePoint
(2*I.getHeight()/3, I.getWidth()/2), I.getWidth()/10.f);
59
// Draws a blue circle on the image
60
// i.e. modifies I_rgb
61
vpImageDraw::drawCircle
(I_rgb, circle3,
vpColor::blue
, 2);
63
64
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
65
std::shared_ptr<vpDisplay>
d
=
vpDisplayFactory::createDisplay
(I_rgb, -1, -1,
""
,
vpDisplay::SCALE_AUTO
);
66
#else
67
vpDisplay
*
d
=
vpDisplayFactory::allocateDisplay
(I_rgb, -1, -1,
""
,
vpDisplay::SCALE_AUTO
);
68
#endif
69
70
vpDisplay::display
(I_rgb);
71
vpDisplay::setTitle
(I_rgb,
"Display blue circle on a modified color image"
);
72
vpDisplay::flush
(I_rgb);
73
std::cout <<
"Result of displaying a blue circle on a modified color image..."
<< std::endl;
74
std::cout <<
"A click to continue..."
<< std::endl;
75
vpDisplay::getClick
(I_rgb);
76
77
78
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
79
delete
d
;
80
#endif
81
}
82
83
84
#else
85
std::cout <<
"No gui available to display an image..."
<< std::endl;
86
#endif
87
88
return
EXIT_SUCCESS;
89
}
vpColor
Class to define RGB colors available for display functionalities.
Definition
vpColor.h:157
vpColor::red
static const vpColor red
Definition
vpColor.h:198
vpColor::blue
static const vpColor blue
Definition
vpColor.h:204
vpDisplay
Class that defines generic functionalities for display.
Definition
vpDisplay.h:171
vpDisplay::getClick
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Definition
vpDisplay_uchar.cpp:894
vpDisplay::displayCircle
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
Definition
vpDisplay_uchar.cpp:154
vpDisplay::display
static void display(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:869
vpDisplay::setTitle
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
Definition
vpDisplay_uchar.cpp:1364
vpDisplay::flush
static void flush(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:845
vpDisplay::SCALE_AUTO
@ SCALE_AUTO
Definition
vpDisplay.h:177
vpImageCircle
Class that defines a 2D circle in an image.
Definition
vpImageCircle.h:57
vpImageDraw::drawCircle
static void drawCircle(vpImage< unsigned char > &I, const vpImageCircle &circle, unsigned char color, unsigned int thickness=1)
Definition
vpImageDraw.cpp:342
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
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
vpDisplayFactory::createDisplay
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
Definition
vpDisplayFactory.h:142
vpDisplayFactory::allocateDisplay
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
Definition
vpDisplayFactory.h:68
yolo-centering-task-afma6.d
d
Definition
yolo-centering-task-afma6.py:273
tutorial
image
tutorial-draw-circle.cpp
Generated by
1.17.0