18 #ifndef VISION_COMMON_RAD_DISTORTER_H_
19 #define VISION_COMMON_RAD_DISTORTER_H_
26 #include <opencv2/core/eigen.hpp>
35 Eigen::Matrix<T, 2, 1>
Distort(
const T* distortion,
const Eigen::Matrix<T, 3, 3>& intrinsics,
36 const Eigen::Matrix<T, 2, 1>& undistorted_point)
const {
37 T radtan_distortion[4];
38 radtan_distortion[0] = distortion[0];
39 radtan_distortion[1] = distortion[1];
40 radtan_distortion[2] = T(0.0);
41 radtan_distortion[3] = T(0.0);
42 return radtan_distorter_.
Distort(radtan_distortion, intrinsics, undistorted_point);
45 cv::Mat
Undistort(
const cv::Mat& distorted_image,
const Eigen::Matrix3d& intrinsics,
46 const Eigen::VectorXd& distortion)
const final {
47 const Eigen::VectorXd radtan_distortion = RadTanDistortionVector(distortion);
48 return radtan_distorter_.
Undistort(distorted_image, intrinsics, radtan_distortion);
51 Eigen::Vector2d
Undistort(
const Eigen::Vector2d& distorted_point,
const Eigen::Matrix3d& intrinsics,
52 const Eigen::VectorXd& distortion)
const final {
53 const Eigen::VectorXd radtan_distortion = RadTanDistortionVector(distortion);
54 return radtan_distorter_.
Undistort(distorted_point, intrinsics, radtan_distortion);
58 Eigen::VectorXd RadTanDistortionVector(
const Eigen::VectorXd& rad_distortion)
const {
59 Eigen::VectorXd radtan_distortion(4);
60 radtan_distortion[0] = rad_distortion[0];
61 radtan_distortion[1] = rad_distortion[1];
62 radtan_distortion[2] = 0;
63 radtan_distortion[3] = 0;
64 return radtan_distortion;
67 RadTanDistorter radtan_distorter_;
71 #endif // VISION_COMMON_RAD_DISTORTER_H_