【问题标题】:SystemError: new style getargs format but argument is not a tuple?SystemError:新样式 getargs 格式但参数不是元组?
【发布时间】:2015-12-16 20:42:19
【问题描述】:

是什么导致了这行代码中的 SystemError cv2.line(output, point1, point2, (0,0,255), 5)?

【问题讨论】:

标签: python opencv


【解决方案1】:

遇到同样的问题,用元组代替列表解决了:

# How it looked before:
point1, point2 = [x1, y1], [x2, y2]

# How it should be:
point1, point2 = (x1, y1), (x2, y2)

【讨论】:

  • 面临同样的问题并尝试了您的解决方案,但没有成功。
【解决方案2】:

Python OpenCV 绘图函数将点作为元组。可能您的 point1point2 属于其他类型,例如。 list 也许。所以试试这个

cv2.line(output, tuple(point1), tuple(point2), (0,0,255),5)

引发错误,因为 OpenCV Python 扩展调用函数 PyArg_ParseTuple() 使用不是元组的东西。 [see here]

【讨论】:

    【解决方案3】:

    试试这个...

    point1=(x1,x2)
    point2=(y1,y2)
    new_img=cv2.line(img,point1,point2,(0,0,255),3)
    

    【讨论】:

    • 欢迎来到 Stack Overflow!虽然这段代码可以解决问题,including an explanation 解决问题的方式和原因确实有助于提高帖子的质量,并可能导致更多的赞成票。请记住,您正在为将来的读者回答问题,而不仅仅是现在提问的人。请edit您的回答添加解释并说明适用的限制和假设。
    【解决方案4】:

    传递的参数与所需的参数不匹配。我遇到了同样的问题:

    x = cv2.resize(img, (32*32)).flatten()
    x.resize(3032, 1)
    

    并且,通过将 32*32 修正为 32, 32 来解决它。

    x = cv2.resize(img, (32,32)).flatten()
    x.resize(3032, 1)
    

    【讨论】:

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