Visual Servoing Platform  version 3.3.0
tutorial-bridge-opencv.cpp
#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
#if VISP_HAVE_OPENCV_VERSION >= 0x040000
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#elif VISP_HAVE_OPENCV_VERSION >= 0x020300
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif
int main()
{
#if VISP_HAVE_OPENCV_VERSION >= 0x020300
double u0 = 326.6;
double v0 = 215.0;
double px = 582.7;
double py = 580.6;
double kud = -0.3372;
double kdu = 0.4021;
vpCameraParameters cam(px, py, u0, v0, kud, kdu);
cv::Mat K = (cv::Mat_<double>(3, 3) << cam.get_px(), 0, cam.get_u0(), 0, cam.get_py(), cam.get_v0(), 0, 0, 1);
cv::Mat D = (cv::Mat_<double>(4, 1) << cam.get_kud(), 0, 0, 0);
vpImageIo::read(I, "chessboard.pgm");
cv::Mat image;
cv::Mat imageUndistorted;
cv::undistort(image, imageUndistorted, K, D);
vpImage<unsigned char> IUndistorted;
vpImageConvert::convert(imageUndistorted, IUndistorted);
vpImageIo::write(IUndistorted, "chessboard-undistorted.pgm");
#endif
}
vpCameraParameters::get_py
double get_py() const
Definition: vpCameraParameters.h:330
vpImageConvert::convert
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition: vpImageConvert.cpp:78
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition: vpCameraParameters.h:232
vpImageIo::read
static void read(vpImage< unsigned char > &I, const std::string &filename)
Definition: vpImageIo.cpp:242
vpCameraParameters::get_px
double get_px() const
Definition: vpCameraParameters.h:327
vpImageIo::write
static void write(const vpImage< unsigned char > &I, const std::string &filename)
Definition: vpImageIo.cpp:444
vpCameraParameters::get_v0
double get_v0() const
Definition: vpCameraParameters.h:332
vpImage< unsigned char >
vpCameraParameters::get_u0
double get_u0() const
Definition: vpCameraParameters.h:331
vpCameraParameters::get_kud
double get_kud() const
Definition: vpCameraParameters.h:333