2#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>
8int 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)
53 if (
p.parse(cam, opt_camera_file, opt_camera_name, projModel, I.getWidth(), I.getHeight()) !=
55 std::cout <<
"Cannot found parameters for camera named \"Camera\"" << std::endl;
60 cam.initPersProjWithDistortion(582.7, 580.6, 326.6, 215.0, -0.3372, 0.4021);
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.
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)
Definition of the vpImage class member functions.
XML parser to load and save intrinsic camera parameters.