1 #include <visp3/core/vpConfig.h>
3 #include <visp3/core/vpImageTools.h>
4 #include <visp3/core/vpIoTools.h>
5 #include <visp3/core/vpXmlParserCamera.h>
6 #include <visp3/io/vpImageIo.h>
8 int main(
int argc,
char **argv)
10 #ifdef ENABLE_VISP_NAMESPACE
14 std::string opt_input_image =
"chessboard.jpg";
15 std::string opt_camera_file =
"camera.xml";
16 std::string opt_camera_name =
"Camera";
19 for (
int i = 1; i < argc; i++) {
20 if (std::string(argv[i]) ==
"--image" && i + 1 < argc) {
21 opt_input_image = std::string(argv[i + 1]);
23 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) {
27 opt_camera_name = std::string(argv[i + 1]);
29 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
30 std::cout << argv[0] <<
" [--image <input image (pgm,ppm,jpeg,png,tiff,bmp,ras,jp2)>]"
31 <<
" [--camera-file <xml file>] [--camera-name <name>] [--help] [-h]\n"
33 std::cout <<
"Examples: " << std::endl
34 << argv[0] << std::endl
35 << argv[0] <<
" --image chessboard.jpg --camera-file camera.xml --camera-name Camera" << std::endl;
42 std::cout <<
"Read input image: " << opt_input_image << std::endl;
48 #if defined(VISP_HAVE_PUGIXML)
55 std::cout <<
"Cannot found parameters for camera named \"Camera\"" << std::endl;
64 std::cout << cam << std::endl;
71 std::string output_image = name_we +
"-undistort" + ext;
72 std::cout <<
"Save undistorted image in: " << output_image << std::endl;
77 std::cout <<
"Catch an exception: " << e << std::endl;
Generic class defining intrinsic camera parameters.
vpCameraParametersProjType
@ perspectiveProjWithDistortion
Perspective projection with distortion model.
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
error that can be emitted by ViSP classes.
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
unsigned int getWidth() const
unsigned int getHeight() const
XML parser to load and save 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, bool verbose=true)