【问题标题】:SystemError: new style getargs format but argument is not a tuple in OpenCVSystemError:新样式 getargs 格式,但参数不是 OpenCV 中的元组
【发布时间】:2017-10-16 16:51:16
【问题描述】:

我有这行使用 OpenCV:

xsize = random.uniform(params['reshape_x_limits'][0],params['reshape_x_limits'][1])
ysize = random.uniform(params['reshape_x_limits'][0],params['reshape_x_limits'][1])
cv2.resize(fg,0,fg,xsize,ysize)

这给出了错误

SystemError: new style getargs format but argument is not a tuple

但是根据文档: https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#resize

所有参数都不应该是元组。是什么导致了这个错误?我正在使用 Python 2.7 和 OpenCV 3.3.0.10。

【问题讨论】:

    标签: python opencv


    【解决方案1】:

    从您发布的文档中,您可以在那里看到一个示例:

    resize(src, dst, Size(), 0.5, 0.5, interpolation);
    

    参数Size()是一个元组(width, length)

    另一个例子你可以find in this tutorial about geometric transformations,例如:

    res = cv2.resize(img,(2*width, 2*height), interpolation = cv2.INTER_CUBIC)
    

    【讨论】:

      【解决方案2】:

      根据documentation,dsize 是必需参数,因此必须提供。奇怪的是, d=0 给了我和你一样的错误。 指定 dsize=None 为我解决了这个问题。以下是sn-p:

      a=cv2.imread('lighthouse2.bmp',0)
      b=cv2.resize(a,None,fx=0.5,fy=0.5,interpolation=cv2.INTER_AREA)
      cv2.imshow('',b)
      cv2.waitKey(0)
      

      我正在使用 Python 3.6 和 OpenCv 4.0.0

      【讨论】:

        【解决方案3】:

        好的,很老的帖子,但我浪费了 30 分钟,所以如果有人遇到问题... cv2 文档可能已经过时了...

        在较新版本中的使用是

        destImage = cv.resize(srcImage, Size(), fx, fy, interpolation)
        

        注意 second 参数是元组(如果你有 fx, fy 则可以设为 None

        希望对正在寻找的人有所帮助。

        【讨论】:

          猜你喜欢
          • 2015-12-16
          • 1970-01-01
          • 2018-04-26
          • 1970-01-01
          • 2012-10-24
          • 1970-01-01
          • 1970-01-01
          • 2019-05-02
          • 2023-02-01
          相关资源
          最近更新 更多