Visual Servoing Platform version 3.7.0
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
8using namespace VISP_NAMESPACE_NAME;
9#endif
10
11int 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
22#endif
23
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");
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;
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);
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;
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
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;
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}
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
static const vpColor red
Definition vpColor.h:198
static const vpColor blue
Definition vpColor.h:204
Class that defines generic functionalities for display.
Definition vpDisplay.h:171
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void display(const vpImage< unsigned char > &I)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void flush(const vpImage< unsigned char > &I)
Class that defines a 2D circle in an image.
static void drawCircle(vpImage< unsigned char > &I, const vpImageCircle &circle, unsigned char color, unsigned int thickness=1)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
Definition vpImage.h:131
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.