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
|
//! \example tutorial-viewer.cpp
//! [Include display]
#include <visp3/gui/vpDisplayD3D.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayGTK.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
//! [Include display]
//! [Include io]
#include <visp3/io/vpImageIo.h>
//! [Include io]
int main(int argc, char **argv)
{
if (argc != 2) {
printf("Usage: %s <image name.[pgm,ppm,jpeg,png,tiff,bmp,ras,jp2]>\n", argv[0]);
return EXIT_FAILURE;
}
//! [vpImage construction]
vpImage<vpRGBa> I;
//! [vpImage construction]
//! [vpImage reading]
try {
vpImageIo::read(I, argv[1]);
} catch (...) {
std::cout << "Cannot read image \"" << argv[1] << "\"" << std::endl;
return EXIT_FAILURE;
}
//! [vpImage reading]
try {
//! [vpDisplay construction]
#if defined(VISP_HAVE_X11)
vpDisplayX d(I, vpDisplay::SCALE_AUTO);
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI d(I, vpDisplay::SCALE_AUTO);
#elif defined(HAVE_OPENCV_HIGHGUI)
vpDisplayOpenCV d(I, vpDisplay::SCALE_AUTO);
#elif defined(VISP_HAVE_GTK)
vpDisplayGTK d(I, vpDisplay::SCALE_AUTO);
#elif defined(VISP_HAVE_D3D9)
vpDisplayD3D d(I, vpDisplay::SCALE_AUTO);
#else
std::cout << "No image viewer is available..." << std::endl;
#endif
//! [vpDisplay construction]
//! [vpDisplay set title]
vpDisplay::setTitle(I, "My image");
//! [vpDisplay set title]
//! [vpDisplay display]
vpDisplay::display(I);
vpDisplay::flush(I);
//! [vpDisplay display]
std::cout << "A click to quit..." << std::endl;
//! [vpDisplay get click]
vpDisplay::getClick(I);
//! [vpDisplay get click]
} catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
}
}
|