简体   繁体   English

OpenCV 3.1重映射功能类型值错误

[英]OpenCV 3.1 Remap function Type Value Error

I'm using OpenCV3.1 with python 2.7 to calibrate and rectify a stereo camera setup. 我正在将OpenCV3.1与python 2.7一起使用以校准和纠正立体相机设置。 When I try to apply the rectification and undistortion matrixes to the image using cv2.remap() I get the following error: 当我尝试使用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

My code is this: 我的代码是这样的:

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)

I've tried setting the INTER_CUBIC and BORDER_CONSTANT as int(1) and int(0) interchangably. 我尝试将INTER_CUBIC和BORDER_CONSTANT设置为可互换地设置为int(1)和int(0)。 I have also added the np.zeros(3) scalar at the end, but the error remained the same in all of my attempts. 我还在末尾添加了np.zeros(3)标量,但是在我的所有尝试中该错误均保持不变。

The use as described in the documentation is wrong. 文档中描述的使用是错误的。 It should be : 它应该是 :

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

Border mode is entirely optional, and so is borderValue. 边框模式是完全可选的,borderValue也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM