假设我从具有185ºFoV的鱼眼摄像头拍摄这张扭曲的图像。使用视场模型的反向鱼眼径向畸变
我想用的FoV模型Frederic Devernay, Olivier Faugeras. Straight lines have to be straight: automatic calibration and removal of distortion from scenes of structured enviroments. Machine Vision and Applications, Springer Verlag, 2001, 13 (1), pp.14-24解释undistort它,具体的公式13和14
rd = 1/ω * arctan (2 * ru * tan(ω/2)) // Equation 13
ru = tan(rd * ω)/(2 * tan(ω/2)) // Equation 14
我已经实现了它在OpenCV中,我无法实现它工作。我将rd
解释为距离光学中心的点的扭曲距离,并将ru
解释为新的未失真距离。
我让你一个完整的最小项目。
#include <opencv2/opencv.hpp>
#define W (185*CV_PI/180)
cv::Mat undistortFishEye(const cv::Mat &distorted, const float w)
{
cv::Mat map_x, map_y;
map_x.create(distorted.size(), CV_32FC1);
map_y.create(distorted.size(), CV_32FC1);
int Cx = distorted.cols/2;
int Cy = distorted.rows/2;
for (int x = -Cx; x < Cx; ++x) {
for (int y = -Cy; y < Cy; ++y) {
double rd = sqrt(x*x+ y*y);
double ru = tan(rd*w)/(2*tan(w/2));
map_x.at<float>(y+Cy,x+Cx) = ru/rd * x + Cx;
map_y.at<float>(y+Cy,x+Cx) = ru/rd * y + Cy;
}
}
cv::Mat undistorted;
remap(distorted, undistorted, map_x, map_y, CV_INTER_LINEAR);
return undistorted;
}
int main(int argc, char **argv)
{
cv::Mat im_d = cv::imread(<your_image_path>, CV_LOAD_IMAGE_GRAYSCALE);
cv::imshow("Image distorted", im_d);
cv::Mat im_u = undistortFishEye(im_d, W);
cv::imshow("Image undistorted", im_u);
cv::waitKey(0);
}
我怀疑错误在FoV模型输入值中。例如,左上方像素'(-575,-543)'有'rd = 790,87',FoV模型返回'ru = 0,012'。 –
检查它可能会帮助你: –
https://github.com/ethz-asl/ethzasl_ptam/blob/e761e802c6382bfe7c09f5f2db342c7a89209348/ptam/src/ATANCamera.cc#L52 –