Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
tutorial-draw-cross.cpp
1 #include <visp3/core/vpConfig.h>
3 #include <visp3/gui/vpDisplayFactory.h>
4 
5 int main()
6 {
7 #ifdef ENABLE_VISP_NAMESPACE
8  using namespace VISP_NAMESPACE_NAME;
9 #endif
10 
11  vpImage<unsigned char> I(2160, 3840, 128);
12 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
13  std::shared_ptr<vpDisplay> pdisplay = vpDisplayFactory::createDisplay(I, -1, -1, "Drawing a cross.", vpDisplay::SCALE_AUTO);
14 #else
15  vpDisplay *pdisplay = vpDisplayFactory::allocateDisplay(I, -1, -1, "Drawing a cross.", vpDisplay::SCALE_AUTO);
16 #endif
17 
18  try {
19  vpDisplay::setTitle(I, "My image");
22  vpDisplay::displayCross(I, I.getHeight() / 2, I.getWidth() / 2, I.getWidth() / 2, vpColor::red, 2);
25  std::cout << "A click to quit..." << std::endl;
27  }
28  catch (const vpException &e) {
29  std::cout << "Catch an exception: " << e.getMessage() << std::endl;
30  }
31  std::cout << std::endl;
32 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
33  delete pdisplay;
34 #endif
35  return 0;
36 }
static const vpColor red
Definition: vpColor.h:217
Class that defines generic functionalities for display.
Definition: vpDisplay.h:178
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
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:184
error that can be emitted by ViSP classes.
Definition: vpException.h:60
const char * getMessage() const
Definition: vpException.cpp:65
unsigned int getWidth() const
Definition: vpImage.h:242
unsigned int getHeight() const
Definition: vpImage.h:181
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.