img = cv.rectangle( img, pt1, pt2, color[, thickness[, lineType[, shift]]] )
img = cv.rectangle( img, rec, color[, thickness[, lineType[, shift]]] )
问题
- {TypeError}an integer is required (got type tuple)
- {TypeError}argument for rectangle() given by name (‘color’) and position (3)
- {TypeError}argument for rectangle() given by name (‘thickness’) and position (4)
- {TypeError}an integer is required (got type tuple)
解决办法
- 坐标pt1,pt2需要是整型
- img=np.ascontiguousarray(img),然后调用rectangle
本文解决了使用cv.rectangle()函数时遇到的TypeError问题,详细解释了如何确保坐标为整型及通过np.ascontiguousarray()预处理图像以避免错误。
3755

被折叠的 条评论
为什么被折叠?



