Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
tutorial-draw-circle.cpp
1
2#include <visp3/gui/vpDisplayGDI.h>
3#include <visp3/gui/vpDisplayX.h>
4#include <visp3/core/vpImageCircle.h>
5#include <visp3/core/vpImageDraw.h>
6
7int main()
8{
9 vpImage<unsigned char> I(2160, 3840, 128);
10 vpImage<vpRGBa> I_rgb(2160, 3840, vpColor(0, 0, 0));
11
12 try {
13 {
14#if defined(VISP_HAVE_X11)
16#elif defined(VISP_HAVE_GDI)
18#endif
19
20 vpDisplay::setTitle(I, "Gray image");
23 vpImageCircle circle(vpImagePoint(I.getHeight()/3, I.getWidth()/3), I.getWidth()/10.f);
24 // Displays in overlay a red circle on the image
25 // i.e. does not modify I
26 vpDisplay::displayCircle(I, circle, vpColor::red, false, 2);
29 vpDisplay::setTitle(I, "Overlay");
30 std::cout << "Result of displaying a red circle on overlay on the display..." << std::endl;
31 std::cout << "A click to continue..." << std::endl;
33
35 vpImageCircle circle2(vpImagePoint(I.getHeight()/3, 2*I.getWidth()/3), I.getWidth()/10.f);
36 // Draws a white circle on the image
37 // i.e. modifies I
38 vpImageDraw::drawCircle(I, circle2, 255, 2);
42 vpDisplay::setTitle(I, "Modification of a uchar image");
43 std::cout << "Result of the modification of a uchar image..." << std::endl;
44 std::cout << "A click to continue..." << std::endl;
46 }
47
48 {
50 vpImageCircle circle3(vpImagePoint(2*I.getHeight()/3, I.getWidth()/2), I.getWidth()/10.f);
51 // Draws a blue circle on the image
52 // i.e. modifies I_rgb
53 vpImageDraw::drawCircle(I_rgb, circle3, vpColor::blue, 2);
55
56#if defined(VISP_HAVE_X11)
58#elif defined(VISP_HAVE_GDI)
60#endif
61
62 vpDisplay::setTitle(I_rgb, "Color image");
63 vpDisplay::display(I_rgb);
64 vpDisplay::flush(I_rgb);
65 vpDisplay::setTitle(I, "Modification of a vpRGBa image");
66 std::cout << "Result of the modification of a vpRGBa image..." << std::endl;
67 std::cout << "A click to continue..." << std::endl;
69 }
70 }
71 catch (const vpException &e) {
72 std::cout << "Catch an exception: " << e.getMessage() << std::endl;
73 }
74 std::cout << std::endl;
75}
Class to define RGB colors available for display functionalities.
Definition vpColor.h:152
static const vpColor red
Definition vpColor.h:211
static const vpColor blue
Definition vpColor.h:217
Display for windows using GDI (available on any windows 32 platform).
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition vpDisplayX.h:132
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)
error that can be emitted by ViSP classes.
Definition vpException.h:59
const char * getMessage() const
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:135
unsigned int getWidth() const
Definition vpImage.h:242
unsigned int getHeight() const
Definition vpImage.h:184