OpenCV 3.1 重映射函数类型值错误
OpenCV 3.1 Remap function Type Value Error
我正在使用带有 python 2.7 的 OpenCV3.1 来校准和校正立体相机设置。
当我尝试使用 cv2.remap() 将校正和不失真矩阵应用于图像时,出现以下错误:
Traceback (most recent call last):
File "C:\University\Year3\Third Year Project - Gaze Correction\EclipseWorkspace\PythonTest\videoCap.py", line 36, in <module>
stereoCalib.rectify(frames)
File "C:\University\Year3\Third Year Project - Gaze Correction\EclipseWorkspace\PythonTest\Calibrator.py", line 137, in rectify
borderMode=cv2.BORDER_CONSTANT )
TypeError: an integer is required
我的代码是这样的:
new_frames = []
new_img=[]
for i, side in enumerate(("left", "right")):
new_img = cv2.remap(frames[i],
new_img,
self.undistortion_map[side],
self.rectification_map[side],
cv2.INTER_CUBIC,
borderMode=cv2.BORDER_CONSTANT )
new_frames.append(new_img)
我试过将 INTER_CUBIC 和 BORDER_CONSTANT 设置为可互换的 int(1) 和 int(0)。我还在最后添加了 np.zeros(3) 标量,但在我所有的尝试中错误仍然相同。
documentation中描述的用法是错误的。
应该是:
new_img = cv2.remap(src,
map1,
map2,
interpolation=cv2.INTER_<VALUE>)
边框模式完全是可选的,borderValue 也是如此。
我正在使用带有 python 2.7 的 OpenCV3.1 来校准和校正立体相机设置。 当我尝试使用 cv2.remap() 将校正和不失真矩阵应用于图像时,出现以下错误:
Traceback (most recent call last):
File "C:\University\Year3\Third Year Project - Gaze Correction\EclipseWorkspace\PythonTest\videoCap.py", line 36, in <module>
stereoCalib.rectify(frames)
File "C:\University\Year3\Third Year Project - Gaze Correction\EclipseWorkspace\PythonTest\Calibrator.py", line 137, in rectify
borderMode=cv2.BORDER_CONSTANT )
TypeError: an integer is required
我的代码是这样的:
new_frames = []
new_img=[]
for i, side in enumerate(("left", "right")):
new_img = cv2.remap(frames[i],
new_img,
self.undistortion_map[side],
self.rectification_map[side],
cv2.INTER_CUBIC,
borderMode=cv2.BORDER_CONSTANT )
new_frames.append(new_img)
我试过将 INTER_CUBIC 和 BORDER_CONSTANT 设置为可互换的 int(1) 和 int(0)。我还在最后添加了 np.zeros(3) 标量,但在我所有的尝试中错误仍然相同。
documentation中描述的用法是错误的。 应该是:
new_img = cv2.remap(src,
map1,
map2,
interpolation=cv2.INTER_<VALUE>)
边框模式完全是可选的,borderValue 也是如此。