1 #include <visp3/core/vpImageTools.h> 3 #include <visp3/core/vpIoTools.h> 4 #include <visp3/core/vpXmlParserCamera.h> 5 #include <visp3/io/vpImageIo.h> 8 main(
int argc,
char **argv )
10 std::string opt_input_image =
"chessboard.jpg";
11 std::string opt_camera_file =
"camera.xml";
12 std::string opt_camera_name =
"Camera";
16 for (
int i = 1; i < argc; i++ )
18 if ( std::string( argv[i] ) ==
"--image" && i + 1 < argc )
20 opt_input_image = std::string( argv[i + 1] );
22 else if ( std::string( argv[i] ) ==
"--camera-file" && i + 1 < argc )
24 opt_camera_file = std::string( argv[i + 1] );
26 else if ( std::string( argv[i] ) ==
"--camera-name" && i + 1 < argc )
28 opt_camera_name = std::string( argv[i + 1] );
30 else if ( std::string( argv[i] ) ==
"--help" || std::string( argv[i] ) ==
"-h" )
32 std::cout << argv[0] <<
" [--image <input image (pgm,ppm,jpeg,png,tiff,bmp,ras,jp2)>]" 33 <<
" [--camera-file <xml file>] [--camera-name <name>] [--help] [-h]\n" 35 std::cout <<
"Examples: " << std::endl
36 << argv[0] << std::endl
37 << argv[0] <<
" --image chessboard.jpg --camera-file camera.xml --camera-name Camera" << std::endl;
44 std::cout <<
"Read input image: " << opt_input_image << std::endl;
56 std::cout <<
"Cannot found parameters for camera named \"Camera\"" << std::endl;
65 std::cout << cam << std::endl;
72 std::string output_image = name_we +
"-undistort" + ext;
73 std::cout <<
"Save undistorted image in: " << output_image << std::endl;
79 std::cout <<
"Catch an exception: " << e << std::endl;
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
error that can be emited by ViSP classes.
XML parser to load and save intrinsic camera parameters.
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
vpCameraParametersProjType
Generic class defining intrinsic camera parameters.
int parse(vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, const vpCameraParameters::vpCameraParametersProjType &projModel, unsigned int image_width=0, unsigned int image_height=0)
unsigned int getHeight() const
unsigned int getWidth() const