Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python SystemError:新样式getargs格式,但参数不是元组?_Python_Opencv - Fatal编程技术网

Python SystemError:新样式getargs格式,但参数不是元组?

Python SystemError:新样式getargs格式,但参数不是元组?,python,opencv,Python,Opencv,是什么导致这行代码中出现SystemError cv2.line(输出,点1,点2,(0,0255),5)?面临同样的问题,并通过使用元组而不是列表来解决: # How it looked before: point1, point2 = [x1, y1], [x2, y2] # How it should be: point1, point2 = (x1, y1), (x2, y2) Python OpenCV绘图函数将点作为元组。您的点1和点2可能属于其他类型,例如列表可能。所以试试这个

是什么导致这行代码中出现SystemError
cv2.line(输出,点1,点2,(0,0255),5)

面临同样的问题,并通过使用元组而不是列表来解决:

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

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

Python OpenCV绘图函数将点作为元组。您的
点1
点2
可能属于其他类型,例如
列表
可能。所以试试这个

cv2.line(output, tuple(point1), tuple(point2), (0,0,255),5)
出现错误是因为OpenCV Python扩展使用非元组的内容调用函数

试试这个

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

传递的参数与所需的参数不匹配。我曾因以下原因面临同样的问题:

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)

听起来和你的问题一样。是
point1
point2
元组吗?你能在问题中发布完整的错误吗?同时发布完整的代码,看看这些变量是什么。面对同样的问题,尝试了你的解决方案,但没有成功。欢迎使用堆栈溢出!虽然这段代码可以解决这个问题,但如何以及为什么解决这个问题将真正有助于提高您的帖子质量,并可能导致更多的投票。请记住,你是在将来回答读者的问题,而不仅仅是现在提问的人。请在回答中添加解释,并说明适用的限制和假设。