【问题标题】:Where is the error? "SystemError: new style getargs format but argument is not a tuple"错误在哪里? “SystemError:新样式的 getargs 格式,但参数不是元组”
【发布时间】:2018-04-26 13:58:43
【问题描述】:

我正在做一个图像处理车道检测项目。我在我的代码中收到此错误。我希望有人能帮我弄清楚如何解决这个错误。

函数如下:

def draw_lane_lines(image, lines, color = [255,0,0], thickness=20):
  line_image=np.zeros_like(image)
  for line in lines:
    if line is not None:
    cv2.line(*(line_image, [line], color, thickness))

错误的名称是:SystemError: new style getargs format but argument is not a tuple。

错误似乎在代码的最后一行。

【问题讨论】:

  • 在做任何其他事情之前修复你的缩进。
  • 您为什么使用cv2.line(*(...)) 而不仅仅是cv2.line(...)

标签: python numpy image-processing


【解决方案1】:

您在问题的根源上是正确的;这是 cv2.line 函数。 看看这个: https://pythonprogramming.net/drawing-writing-python-opencv-tutorial/

我认为你的颜色需要是一个元组 (255,0,0) 而不是一个列表 [255,0,0]

编辑:你的行 arg 可能会有同样的问题...我认为它也需要是一个元组。

【讨论】:

    【解决方案2】:

    不确定该库如何格式化颜色,但通常它位于圆括号 (255,36,239) 中,这可能是关于元组的错误。其次,在定义参数时不要使用等号(=)。 这个:

    color = [255,0,0]
    

    应改为:

    colour = (255,0,0)
    , color, thickness..
    

    同样改变粗细。

    【讨论】:

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