疑問:undistortPoints()與remap()畸變校正後,結果相差很大

    最近在做圖像點畸變校正相關的項目,發現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
                                                                                  圖1
使用undistortPoints()進行校正特徵點,結果如圖2

圖2
                                                                                  圖2
使用initUndistortRectifyMap()和remap()組合進行畸變校正結果如圖3
圖3
                                                                                  圖3
    從結果可看出undistortPoints()校正效果特別不明顯,原因不明,如有懂得小夥伴請指點一二,非常感謝~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章