【问题标题】:OpenCV 3.1 Remap function Type Value ErrorOpenCV 3.1 重映射函数类型值错误
【发布时间】:2016-02-12 16:21:11
【问题描述】:

我正在使用 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) 标量,但在我的所有尝试中,错误都保持不变。

【问题讨论】:

    标签: python c++ opencv computer-vision stereoscopy


    【解决方案1】:

    documentation 中描述的用法是错误的。 应该是:

    new_img = cv2.remap(src,
                        map1,
                        map2,
                        interpolation=cv2.INTER_<VALUE>)
    

    边框模式是完全可选的,borderValue 也是如此。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-29
      • 1970-01-01
      • 1970-01-01
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多