Python SystemError:新样式 getargs 格式但参数不是元组?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32673359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SystemError: new style getargs format but argument is not a tuple?
提问by JDOdle
Sorry if this is trivial but I am just learning python, I am getting this error for this line of code: cv2.line(output, point1, point2, (0,0,255),5)
抱歉,如果这是微不足道的,但我只是在学习 python,这行代码出现此错误: cv2.line(output, point1, point2, (0,0,255),5)
I don't see the problem...
我看不出问题...
回答by Leonid Dashko
Faced with the same problem and solved it by using tuples instead of lists:
面临同样的问题并通过使用元组而不是列表来解决它:
# How it looked before:
point1, point2 = [x1, y1], [x2, y2]
# How it should be:
point1, point2 = (x1, y1), (x2, y2)
回答by zardosht
Python OpenCV drawing functions take points as tuples. Possibly your point1
and point2
are of some other type, eg. a list
maybe. So try this
Python OpenCV 绘图函数将点作为元组。可能你的point1
和point2
是其他类型的,例如。一个list
也许。所以试试这个
cv2.line(output, tuple(point1), tuple(point2), (0,0,255),5)
The error is raised, because the OpenCV Python extensions call the function PyArg_ParseTuple()
with something that is not a tuple. [see here]
引发错误,因为 OpenCV Python 扩展PyArg_ParseTuple()
使用不是元组的东西调用函数。[看这里]
回答by praveen kumar dakua
Try this...
尝试这个...
point1=(x1,x2)
point2=(y1,y2)
new_img=cv2.line(img,point1,point2,(0,0,255),3)