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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/**
\page tutorial-image-display Tutorial: How to display an image in a window
\tableofcontents
\section image_display_intro Introduction
\note We assume in this tutorial that you have successfully build your first project using ViSP as 3rd party as explained in one of the \ref tutorial_started tutorials.
In this tutorial you will learn how to display an image in a window with ViSP either on Unix-like systems (including OSX, Fedora, Ubuntu, Debian, ...) or on Windows.
Note 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:
\code
$ svn export https://github.com/lagadic/visp.git/trunk/tutorial/image
\endcode
\section image_display_default Create and display an image in a window
ViSP <a href="https://visp.inria.fr/gui/">gui module</a> provides Graphical User Interfaces capabilities that allows to display a vpImage in a window. To this end you may use several optional third-party libraries which are: <a href="https://visp.inria.fr/3rdparty_gui/">X11, GDI, OpenCV, GTK, Direct3D</a>. We recommend to use X11 on unix-like systems thanks to vpDisplayX class and GDI on Windows thanks to vpDisplayGDI. If none of these classes are available, you may use vpDisplayOpenCV instead.
The following example also available in tutorial-image-display.cpp shows how to create a gray level 3840x2160 image with all the pixels set to 128, and display a red circle with 200 pixel radius in the middle of the image.
\include tutorial-image-display.cpp
Depending on your screen resolution you may just see a part of the image, and certainly not the full red circle. Next image shows an example of this behavior when screen resolution is less than image size:
\image html img-tutorial-display.png
\note A vpImage can only be associated to one display window. In the previous example, image `I` is associated to display `d`. Depending on your platform, object `d` is either a vpDisplayX or a vpDisplayGDI.
\section image_display_scaled Display an image that is larger than the screen resolution
\subsection image_display_scaled_manu Setting a manual down scaling factor
This other example available in tutorial-image-display-scaled-manu.cpp shows how to modify the previous example in order to introduce a down scaling factor to reduce the size of the display by 5 along the lines and the columns. This feature may be useful to display images that are larger than the screen resolution.
To down scale the display size, just modify the previous example adding the vpDisplay::vpScaleType parameter to the constructor.
\snippet tutorial-image-display-scaled-manu.cpp vpDisplay scale manu
It is also possible to do the same using the default constructor:
\code
#if defined(VISP_HAVE_X11)
vpDisplayX d;
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI d;
#endif
d.setDownScalingFactor(vpDisplay::SCALE_5);
d.init(I);
}
\endcode
\subsection image_display_scaled_auto Setting an auto down scaling factor
This other example available in tutorial-image-display-scaled-auto.cpp shows now how to modify the previous example in order to introduce an auto down scaling factor that is automatically computed from the screen resolution in order that two images could be displayed given the screen resolution.
To consider an auto down scaling factor, modify the previous example adding the vpDisplay::SCALE_AUTO parameter to the constructor.
\snippet tutorial-image-display-scaled-auto.cpp vpDisplay scale auto
It is also possible to do the same using the default constructor:
\code
#if defined(VISP_HAVE_X11)
vpDisplayX d;
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI d;
#endif
d.setDownScalingFactor(vpDisplay::SCALE_AUTO);
d.init(I);
}
\endcode
Next image shows the content of the display window:
\image html img-tutorial-display-scaled-auto.png
\section image_display_next Next tutorial
You are now ready to see the \ref tutorial-grabber or \ref tutorial-image-filtering.
*/
|