Visual Servoing Platform  version 3.6.1 under development (2024-02-13)
drawingHelpers.cpp
1 #include "drawingHelpers.h"
2 
3 #include <visp3/core/vpImageConvert.h>
4 
5 #if defined(VISP_HAVE_X11)
7 #elif defined(VISP_HAVE_OPENCV)
9 #elif defined(VISP_HAVE_GTK)
11 #elif defined(VISP_HAVE_GDI)
13 #elif defined(VISP_HAVE_D3D9)
15 #endif
16 
18 
19 bool drawingHelpers::display(vpImage<vpRGBa> &I, const std::string &title, const bool &blockingMode)
20 {
21  I_disp = I;
22 #if defined(VISP_HAVE_DISPLAY)
23  if (!d.isInitialised()) {
24  d.init(I_disp);
26  }
27 #else
28  (void)title;
29 #endif
30 
32  vpDisplay::displayText(I_disp, 15, 15, "Left click to continue...", vpColor::red);
33  vpDisplay::displayText(I_disp, 35, 15, "Right click to stop...", vpColor::red);
36  vpDisplay::getClick(I_disp, button, blockingMode);
37  bool hasToContinue = true;
38  if (button == vpMouseButton::button3) {
39  // Right click => stop the program
40  hasToContinue = false;
41  }
42 
43  return hasToContinue;
44 }
45 
46 bool drawingHelpers::display(vpImage<unsigned char> &D, const std::string &title, const bool &blockingMode)
47 {
48  vpImage<vpRGBa> I; // Image to display
50  return display(I, title, blockingMode);
51 }
52 
53 bool drawingHelpers::display(vpImage<double> &D, const std::string &title, const bool &blockingMode)
54 {
55  vpImage<unsigned char> I; // Image to display
57  return display(I, title, blockingMode);
58 }
static const vpColor red
Definition: vpColor.h:211
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Definition: vpDisplayD3D.h:101
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:128
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:128
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:128
void init(vpImage< unsigned char > &I, int win_x=-1, int win_y=-1, const std::string &win_title="") vp_override
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
bool isInitialised()
Definition: vpDisplay.h:259
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
vpImage< vpRGBa > I_disp
void display(vpImage< unsigned char > &I, const std::string &title)
Display a gray-scale image.