File: drawingHelpers.cpp

package info (click to toggle)
visp 3.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 119,296 kB
  • sloc: cpp: 500,914; ansic: 52,904; xml: 22,642; python: 7,365; java: 4,247; sh: 482; makefile: 237; objc: 145
file content (58 lines) | stat: -rw-r--r-- 1,642 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "drawingHelpers.h"

#include <visp3/core/vpImageConvert.h>

#if defined(VISP_HAVE_X11)
vpDisplayX drawingHelpers::d;
#elif defined(VISP_HAVE_OPENCV)
vpDisplayOpenCV drawingHelpers::d;
#elif defined(VISP_HAVE_GTK)
vpDisplayGTK drawingHelpers::d;
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI drawingHelpers::d;
#elif defined(VISP_HAVE_D3D9)
vpDisplayD3D drawingHelpers::d;
#endif

vpImage<vpRGBa> drawingHelpers::I_disp;

bool drawingHelpers::display(vpImage<vpRGBa> &I, const std::string &title, const bool &blockingMode)
{
  I_disp = I;
#if defined(VISP_HAVE_DISPLAY)
  if (!d.isInitialised()) {
    d.init(I_disp);
    vpDisplay::setTitle(I_disp, title);
  }
#else
  (void)title;
#endif

  vpDisplay::display(I_disp);
  vpDisplay::displayText(I_disp, 15, 15, "Left click to continue...", vpColor::red);
  vpDisplay::displayText(I_disp, 35, 15, "Right click to stop...", vpColor::red);
  vpDisplay::flush(I_disp);
  vpMouseButton::vpMouseButtonType button;
  vpDisplay::getClick(I_disp, button, blockingMode);
  bool hasToContinue = true;
  if (button == vpMouseButton::button3) {
    // Right click => stop the program
    hasToContinue = false;
  }

  return hasToContinue;
}

bool drawingHelpers::display(vpImage<unsigned char> &D, const std::string &title, const bool &blockingMode)
{
  vpImage<vpRGBa> I; // Image to display
  vpImageConvert::convert(D, I);
  return display(I, title, blockingMode);
}

bool drawingHelpers::display(vpImage<double> &D, const std::string &title, const bool &blockingMode)
{
  vpImage<unsigned char> I; // Image to display
  vpImageConvert::convert(D, I);
  return display(I, title, blockingMode);
}