Visual Servoing Platform  version 3.6.1 under development (2024-07-27)
drawingHelpers.cpp
1 #include "drawingHelpers.h"
2 
3 #include <visp3/core/vpImageConvert.h>
4 
5 #ifndef DOXYGEN_SHOULD_SKIP_THIS
6 
7 #ifdef ENABLE_VISP_NAMESPACE
8 using namespace VISP_NAMESPACE_NAME;
9 #endif
10 
11 #if defined(VISP_HAVE_X11)
12 vpDisplayX drawingHelpers::d;
13 #elif defined(VISP_HAVE_OPENCV)
14 vpDisplayOpenCV drawingHelpers::d;
15 #elif defined(VISP_HAVE_GTK)
16 vpDisplayGTK drawingHelpers::d;
17 #elif defined(VISP_HAVE_GDI)
18 vpDisplayGDI drawingHelpers::d;
19 #elif defined(VISP_HAVE_D3D9)
20 vpDisplayD3D drawingHelpers::d;
21 #endif
22 
23 vpImage<vpRGBa> drawingHelpers::I_disp;
24 
25 bool drawingHelpers::display(vpImage< vpRGBa> &I, const std::string &title, const bool &blockingMode)
26 {
27  I_disp = I;
28 #if defined(VISP_HAVE_DISPLAY)
29  if (!d.isInitialised()) {
30  d.init(I_disp);
31  vpDisplay::setTitle(I_disp, title);
32  }
33 #else
34  (void)title;
35 #endif
36 
37  vpDisplay::display(I_disp);
38  vpDisplay::displayText(I_disp, 15, 15, "Left click to continue...", vpColor::red);
39  vpDisplay::displayText(I_disp, 35, 15, "Right click to stop...", vpColor::red);
40  vpDisplay::flush(I_disp);
42  vpDisplay::getClick(I_disp, button, blockingMode);
43  bool hasToContinue = true;
44  if (button == vpMouseButton::button3) {
45  // Right click => stop the program
46  hasToContinue = false;
47  }
48 
49  return hasToContinue;
50 }
51 
52 bool drawingHelpers::display(vpImage<unsigned char> &D, const std::string &title, const bool &blockingMode)
53 {
54  vpImage<vpRGBa> I; // Image to display
56  return display(I, title, blockingMode);
57 }
58 
59 bool drawingHelpers::display(vpImage<double> &D, const std::string &title, const bool &blockingMode)
60 {
61  vpImage<unsigned char> I; // Image to display
63  return display(I, title, blockingMode);
64 }
65 
66 #endif
static const vpColor red
Definition: vpColor.h:217
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Definition: vpDisplayD3D.h:106
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:130
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:133
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:135
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:249
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)