Skip to content

Commit

Permalink
Fix build when no display gui available
Browse files Browse the repository at this point in the history
- error reported by ros2 jenkins buildfarm
  • Loading branch information
fspindle committed Oct 27, 2023
1 parent af97521 commit 11ca9fc
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions tutorial/image/drawingHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,52 @@
#include <visp3/core/vpImageConvert.h>

#if defined(VISP_HAVE_X11)
vpDisplayX drawingHelpers::d;
vpDisplayX drawingHelpers::d;
#elif defined(HAVE_OPENCV_HIGHGUI)
vpDisplayOpenCV drawingHelpers::d;
vpDisplayOpenCV drawingHelpers::d;
#elif defined(VISP_HAVE_GTK)
vpDisplayGTK drawingHelpers::d;
vpDisplayGTK drawingHelpers::d;
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI drawingHelpers::d;
vpDisplayGDI drawingHelpers::d;
#elif defined(VISP_HAVE_D3D9)
vpDisplayD3D drawingHelpers::d;
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;
d.init(I_disp);
vpDisplay::setTitle(I_disp, title.c_str());

#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)
{
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)
{
Expand Down

0 comments on commit 11ca9fc

Please sign in to comment.