转载请注明出处。
文章地址:https://blog.csdn.net/duiwangxiaomi/article/details/102552950?spm=1001.2014.3001.5501
最近在做图像点畸变校正相关的项目,发现OpenCV中的校正函数:undistortPoints()与remap()二者矫正畸变后,结果相差很大,原因不明,这里记录下来,如有大神知其中差异,请赐教,感激不尽,欢迎在博客下方评论。
下面先说一下函数的用法
undistortPoints()函数用法说明
void undistortPoints(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArrayR=noArray(), InputArray P=noArray())
参数说明:
正确调用方法:
调用方法
std::vectorcv::Point2f inputDistortedPoints = …
std::vectorcv::Point2f outputUndistortedPoints;
cv::Mat cameraMatrix = …
cv::Mat distCoeffs = …
cv::undistortPoints(inputDistortedPoints, outputUndistortedPoints, cameraMatrix, distCoeffs, cv::noArray(), cameraMatrix);
不要像下面这样调用,输出的点为图像物理坐标系下坐标,结果很小,需再乘内参矩阵得到像面点坐标
cv::undistortPoints(inputDistortedPoints, outputUndistortedPoints, cameraMatrix, distCoeffs)
关于initUndistortRectifyMap()和remap()组合进行畸变校正的用法可参考如下博客,这里不再详述:
remap()畸变校正参考博客
二者进行畸变校正后的比较,首先提取出了未进行畸变校正的一些特征点,如图1所示
图1
使用undistortPoints()进行校正特征点,结果如图2
图2
使用initUndistortRectifyMap()和remap()组合进行畸变校正结果如图3
图3
从结果可看出undistortPoints()校正效果特别不明显,原因不明,如有懂得小伙伴请指点一二,非常感谢~
更新
最近有时间,根据下面博友评论中的链接重新做了一次两种畸变校正方法效果对比,发现二者差异不大,现附上链接,有兴趣的伙伴可以试试,欢迎讨论~
在此也非常感谢“stick02”这位博友的评论,解开了本人好久的困惑,同时也印证了分享的重要性,遂花了些时间再次写篇博客和大家分享,觉得写得不错的欢迎点赞打赏哦~
OpenCV 畸变校正函数undistortPoints()与remap()详解及校正效果对比