Visual Servoing Platform  version 3.6.1 under development (2024-11-14)
tutorial-image-reader.cpp
1 
2 #include <visp3/core/vpConfig.h>
3 #include <visp3/io/vpImageIo.h>
4 
5 int main()
6 {
7 #ifdef ENABLE_VISP_NAMESPACE
8  using namespace VISP_NAMESPACE_NAME;
9 #endif
10 
11  try {
13  vpImageIo::read(I, "monkey.jpeg");
14  vpImageIo::write(I, "monkey.png");
15  }
16  catch (const vpException &e) {
17  std::cout << e.getMessage() << std::endl;
18  }
19  catch (...) {
20  std::cout << "Unsupported image format" << std::endl;
21  }
22 }
error that can be emitted by ViSP classes.
Definition: vpException.h:60
const char * getMessage() const
Definition: vpException.cpp:65
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:147
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:291