Visual Servoing Platform  version 3.1.0
tutorial-undistort.cpp
1 #include <visp3/core/vpImageTools.h>
3 #include <visp3/core/vpXmlParserCamera.h>
4 #include <visp3/io/vpImageIo.h>
5 
6 int main()
7 {
8  try {
11  vpImageIo::read(I, "chessboard.pgm");
13 
16 #ifdef VISP_HAVE_XML2
20  if (p.parse(cam, "camera.xml", "Camera", projModel, I.getWidth(), I.getHeight()) !=
22  std::cout << "Cannot found parameters for camera named \"Camera\"" << std::endl;
23  }
26 #else
27  cam.initPersProjWithDistortion(582.7, 580.6, 326.6, 215.0, -0.3372, 0.4021);
28 #endif
29 
31  std::cout << cam << std::endl;
32 
35  vpImageTools::undistort(I, cam, Iud);
36  vpImageIo::write(Iud, "chessboard-undistort.pgm");
38  } catch (vpException &e) {
39  std::cout << "Catch an exception: " << e << std::endl;
40  }
41 
42  return 0;
43 }
error that can be emited by ViSP classes.
Definition: vpException.h:71
XML parser to load and save intrinsic camera parameters.
static void write(const vpImage< unsigned char > &I, const std::string &filename)
Definition: vpImageIo.cpp:375
Generic class defining intrinsic camera parameters.
static void undistort(const vpImage< Type > &I, const vpCameraParameters &cam, vpImage< Type > &newI)
Definition: vpImageTools.h:579
unsigned int getHeight() const
Definition: vpImage.h:178
static void read(vpImage< unsigned char > &I, const std::string &filename)
Definition: vpImageIo.cpp:207
int parse(vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, const vpCameraParameters::vpCameraParametersProjType &projModel, const unsigned int image_width=0, const unsigned int image_height=0)
unsigned int getWidth() const
Definition: vpImage.h:229
void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0, const double kud, const double kdu)