1/**
2  \page tutorial-image-display-overlay Tutorial: How to display an image and basic drawings in a window
3  \tableofcontents
4
5\section display_overlay_intro Introduction
6
7In this tutorial you will learn how to display basic drawings with ViSP either on Unix-like systems (including OSX, Fedora, Ubuntu, Debian, ...) or on Windows.
8
9Note that all the material (source code and images) described in this tutorial is part of ViSP source code and could be downloaded using the following command:
10
11\code
12$ svn export https://github.com/lagadic/visp.git/trunk/tutorial/image
13\endcode
14
15\section display_overlay_default Load and display an image
16
17ViSP <a href="https://visp.inria.fr/gui/">gui module</a> provides Graphical User Interfaces capabilities. To this end you may use several optional third-party libraries which are: <a href="http://visp.inria.fr/3rdparty_gui/">X11, GDI, OpenCV, GTK, Direct3D</a>. In the next example, we will use the first 3rd party that is available from the previous list.
18
19The following example also available in tutorial-viewer.cpp shows how to read and display an image.
20
21\include tutorial-viewer.cpp
22
23Once build, if you run the corresponding binary loading `monkey.png` image:
24\code
25$ cd $VISP_WS/visp-build/tutorial/image
26$ ./tutorial-viewer monkey.png
27\endcode
28
29It will open a window containing `monkey.png` image:
30\image html img-monkey.png
31
32Here is the detailed explanation of the source, line by line :
33\snippet tutorial-viewer.cpp Include display
34
35Include all the headers for image viewers. The two first one are for Windows systems. They require that Direct 3D or the \e Graphical \e Device \e Interface (\e GDI) coming with the installation of Visual Studio are available. The third one needs GTK that is cross-platform. The fourth is for unix-like systems and requires that \e libX11 is available. The last one is also cross-platform and requires that OpenCV is available.
36
37\snippet tutorial-viewer.cpp Include io
38Include the header that allows to read/write PGM, PPM, PNG and JPEG images from the disk using vpImageIo class.
39
40\snippet tutorial-viewer.cpp vpImage construction
41Create an instance of a color image where each pixel is coded in RGBa.
42
43\snippet tutorial-viewer.cpp vpImage reading
44The image \c I is initialized by reading an image file from the disk. If the image format is not supported we throw an exception.
45
46\snippet tutorial-viewer.cpp vpDisplay construction
47Create an instance of an image display window for image \c I. The first viewer that is available is used. Here we create the link between the image \c I and the display \c d. Note that an image can only have one display.
48
49\snippet tutorial-viewer.cpp vpDisplay set title
50The title of the display is then set to \c "My image".
51
52\snippet tutorial-viewer.cpp vpDisplay display
53First we display the content of the image \c I, then we flush the display to render the image.
54
55\snippet tutorial-viewer.cpp vpDisplay get click
56Here we handle mouse events. We are waiting for a blocking mouse click to end the program.
57
58\section display_overlay_draw Display basic drawings in window overlay
59
60There are a lot of examples in ViSP that show how to display drawings in window overlay. There is testDisplays.cpp that gives an overview.
61
62If you run the corresponding binary:
63\code
64$ cd $VISP_WS/visp-build/modules/gui
65$ ./testDisplays
66\endcode
67it will open a window like the following:
68\image html img-tutorial-display-drawings.png
69
70\subsection display_overlay_point Display a point in overlay
71
72As shown in tutorial-draw-point.cpp which source code is given below we use vpDisplay::displayPoint() function to draw a point in the overlay of a windows that displays a 3840 by 2160 grey image that has all the pixels set to 128 gray level.
73
74\include tutorial-draw-point.cpp
75
76Here we draw a point at the center of a grey image with red color and thickness 2.
77
78\subsection display_overlay_line Display a line between 2 points in overlay
79
80As given in tutorial-draw-line.cpp we use vpDisplay::displayLine() function to draw a line segment on the screen.
81
82\snippet tutorial-draw-line.cpp Line
83
84Here we draw a red coloured line segment with the specified initial and final coordinates and thickness 10.
85
86\subsection display_overlay_circle Display a circle in overlay
87
88As given in tutorial-image-display-scaled-auto.cpp we use vpDisplay::displayCircle() function to draw a circle on the screen.
89
90\snippet tutorial-image-display-scaled-auto.cpp Circle
91
92Here we draw a red coloured filled circle at the center with radius of 200.
93
94\subsection display_overlay_rectangle Display a rectangle in overlay
95
96As given in tutorial-draw-rectangle.cpp we use vpDisplay::displayRectangle() function to draw a rectangle on the screen.
97
98\snippet tutorial-draw-rectangle.cpp Rectangle
99
100Here we draw a red coloured filled rectangle with specified top-left coordinates and width and height.
101\subsection display_overlay_cross Display a cross in overlay
102
103As given in tutorial-draw-cross.cpp we use vpDisplay::displayCross() function to draw a rectangle on the screen.
104
105\snippet tutorial-draw-cross.cpp Cross
106
107Here we draw a red coloured cross on the center with speicfied size and thickness 2.
108
109\subsection display_overlay_text Display text in window overlay
110
111As given in tutorial-draw-text.cpp we use vpDisplay::displayText() function to add text in the window overlay.
112
113\snippet tutorial-draw-text.cpp text
114
115Here `Hello world` is displayed in the middle of the image.
116
117\section display_overlay_export Export and save the content of a window as an image
118
119As given in tutorial-export-image.cpp which source code is given below, we use vpDisplay::getImage() function to export the image with the whole drawings in overlay. Then we use vpImageIo::write() to save the image in png format.
120
121\include tutorial-export-image.cpp
122
123\section display_overlay_event_keyboard Handle keyboard events in a window
124
125As given in tutorial-event-keyboard.cpp which code is given below, we use vpDisplay::getKeyboardEvent() function to get the value of the key pressed.
126
127\include tutorial-event-keyboard.cpp
128
129\section display_overlay_next Next tutorial
130
131You are now ready to see how to continue with \ref tutorial-basic-drawings.
132
133*/
134