我发现OpenCV的solvePnP()函数假设你的相机参数来自针孔模型。但是我使用了cv.fisheye模块对我的相机进行了校准,因此我想知道如何使用从这个fisheye模块获取的参数和solvePnP一起使用。
我该如何在solvePnP()中使用我的鱼眼相机参数?
我发现OpenCV的solvePnP()函数假设你的相机参数来自针孔模型。但是我使用了cv.fisheye模块对我的相机进行了校准,因此我想知道如何使用从这个fisheye模块获取的参数和solvePnP一起使用。
我该如何在solvePnP()中使用我的鱼眼相机参数?
cv::fisheye::calibrate()
获得 {K, D, rvecs, tvecs}。cv.fisheye.undistortPoints()
从输入坐标 distorted
中消除 K 和 D 的影响,详见 here。undistorted = cv.fisheye.undistortPoints(distorted,K,D)
cv.solvePnP(objPoints, undistorted,I,D)
,其中 I=np.eye(3),D=np.zeros((1,5))
solvePnP
使用的是cv.undistortPoints
而不是cv.fisheye.undistortPoints
。我尝试使用相同的参数评估这两个函数,它们返回不同的结果(即使使用np.eye(3)和np.zeros((1,5))作为相机参数)。这些函数需要使用相同的输出来识别相机矩阵吗? - off99555rvec
和tvec
,做了imgpoints = cv.fisheye.projectPoints(objectPoints,rvec,tvec,K,D)
,然后使用imgpoints
做了如答案所述的solvePnP
。通过实验得到的输出rvec
和tvec
与原始旋转和平移非常接近(有1e-7的误差)。所以这是通过实验证明它有效的! - off99555cv.fishey
中的相机模型使用了不同的镜头畸变模型,与docs.opencv.org
中发现的不同,因此应该使用cv.fisheye.undistortPoints()
来消除畸变效果。 - Yongduek Seocv.fisheye.undistortPoints()
来消除畸变效果。但我不明白为什么cv.undistortPoints(imgpoints, np.eye(3), np.zeros(4))
不等于cv.fisheye.undistortPoints(imgpoints, np.eye(3), np.zeros(4))
。第一个函数对我来说很有意义,它返回与imgpoints
相同的值。但第二个函数返回了我不理解的不同的东西。为什么它们都没有返回imgpoints
? - off99555