ViSP  2.10.0
tutorial-undistort.cpp
1 #include <visp/vpImageIo.h>
3 #include <visp/vpImageTools.h>
4 #include <visp/vpXmlParserCamera.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()) != vpXmlParserCamera::SEQUENCE_OK) {
21  std::cout << "Cannot found parameters for camera named \"Camera\"" << std::endl;
22  }
25 #else
26  cam.initPersProjWithDistortion(582.7, 580.6, 326.6, 215.0, -0.3372, 0.4021);
27 #endif
28 
30  std::cout << cam << std::endl;
31 
34  vpImageTools::undistort(I, cam, Iud);
35  vpImageIo::write(Iud, "chessboard-undistort.pgm");
37  }
38  catch(vpException e) {
39  std::cout << "Catch an exception: " << e << std::endl;
40  }
41 
42  return 0;
43 }
static void write(const vpImage< unsigned char > &I, const char *filename)
Definition: vpImageIo.cpp:476
unsigned int getWidth() const
Definition: vpImage.h:161
error that can be emited by ViSP classes.
Definition: vpException.h:76
XML parser to load and save intrinsic camera parameters.
Generic class defining intrinsic camera parameters.
static void undistort(const vpImage< Type > &I, const vpCameraParameters &cam, vpImage< Type > &newI)
Definition: vpImageTools.h:362
Perspective projection with distortion model.
unsigned int getHeight() const
Definition: vpImage.h:152
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)
static void read(vpImage< unsigned char > &I, const char *filename)
Definition: vpImageIo.cpp:278
void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0, const double kud, const double kdu)