gpt4 book ai didi

python - OpenCV 3.1 重映射函数类型值错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:18:24 24 4
gpt4 key购买 nike

我正在使用 OpenCV3.1 和 python 2.7 来校准和校正立体相机设置。当我尝试使用 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 - OpenCV 3.1 重映射函数类型值错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35367380/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com