Visual Servoing Platform  version 3.6.1 under development (2024-04-27)
tutorial-draw-circle.cpp
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/core/vpImageCircle.h>
#include <visp3/core/vpImageDraw.h>
int main()
{
vpImage<unsigned char> I(2160, 3840, 128);
vpImage<vpRGBa> I_rgb(2160, 3840, vpColor(0, 0, 0));
try {
{
#if defined(VISP_HAVE_X11)
#elif defined(VISP_HAVE_GDI)
#endif
vpDisplay::setTitle(I, "Gray image");
vpImageCircle circle(vpImagePoint(I.getHeight()/3, I.getWidth()/3), I.getWidth()/10.f);
// Displays in overlay a red circle on the image
// i.e. does not modify I
vpDisplay::displayCircle(I, circle, vpColor::red, false, 2);
vpDisplay::setTitle(I, "Overlay");
std::cout << "Result of displaying a red circle on overlay on the display..." << std::endl;
std::cout << "A click to continue..." << std::endl;
vpImageCircle circle2(vpImagePoint(I.getHeight()/3, 2*I.getWidth()/3), I.getWidth()/10.f);
// Draws a white circle on the image
// i.e. modifies I
vpImageDraw::drawCircle(I, circle2, 255, 2);
vpDisplay::setTitle(I, "Modification of a uchar image");
std::cout << "Result of the modification of a uchar image..." << std::endl;
std::cout << "A click to continue..." << std::endl;
}
{
vpImageCircle circle3(vpImagePoint(2*I.getHeight()/3, I.getWidth()/2), I.getWidth()/10.f);
// Draws a blue circle on the image
// i.e. modifies I_rgb
#if defined(VISP_HAVE_X11)
#elif defined(VISP_HAVE_GDI)
#endif
vpDisplay::setTitle(I_rgb, "Color image");
vpDisplay::setTitle(I, "Modification of a vpRGBa image");
std::cout << "Result of the modification of a vpRGBa image..." << std::endl;
std::cout << "A click to continue..." << std::endl;
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e.getMessage() << std::endl;
}
std::cout << std::endl;
}
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).
Definition: vpDisplayGDI.h:128
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:128
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)
@ SCALE_AUTO
Definition: vpDisplay.h:179
error that can be emitted by ViSP classes.
Definition: vpException.h:59
const char * getMessage() const
Definition: vpException.cpp:64
Class that defines a 2D circle in an image.
Definition: vpImageCircle.h:56
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: vpImagePoint.h:82
unsigned int getWidth() const
Definition: vpImage.h:245
unsigned int getHeight() const
Definition: vpImage.h:184