Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tutorial-undistort.cpp
1 #include <visp3/io/vpImageIo.h>
3 #include <visp3/core/vpImageTools.h>
4 #include <visp3/core/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 }
unsigned int getWidth() const
Definition: vpImage.h:226
error that can be emited by ViSP classes.
Definition: vpException.h:73
XML parser to load and save intrinsic camera parameters.
static void write(const vpImage< unsigned char > &I, const std::string &filename)
Definition: vpImageIo.cpp:368
Generic class defining intrinsic camera parameters.
static void undistort(const vpImage< Type > &I, const vpCameraParameters &cam, vpImage< Type > &newI)
Definition: vpImageTools.h:609
Perspective projection with distortion model.
static void read(vpImage< unsigned char > &I, const std::string &filename)
Definition: vpImageIo.cpp:205
unsigned int getHeight() const
Definition: vpImage.h:175
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)
void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0, const double kud, const double kdu)