如何避免由于cv2.undistort引起的延迟?

问题描述 投票:0回答:1

我正在python中使用OpenCV来跟踪对象。首先,我应该校准摄像机,找到属性后,我应该找到对象的精确位置,并且应该是实时的

我找到了此代码

ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1],None,None)
.
.
.

# undistort
dst = cv2.undistort(img, mtx, dist, None, newcameramtx)

因此,根据此代码,我应该使每一帧都保持不失真,这非常耗时,有什么方法可以设置相机参数然后使用机器视觉?或其他方式?

python opencv computer-vision real-time camera-calibration
1个回答
0
投票

undistort的问题在于,每次调用映射时,它都会重新计算从扭曲像素到未扭曲像素的映射。您只需要计算一次坐标变换。您只需要使用cv.initUndistortRectifyMap进行计算即可,它会返回相应的映射(请参见此处的documentation)。然后,您可以使用功能cv.remap

© www.soinside.com 2019 - 2024. All rights reserved.