我想检测汽车牌照的字符。我看到了this post昨天,但是当我运行该程序时出现此错误:
contours,hierarchy = cv2.findContours(imgBWcopy.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack"
为什么?有人有不同的检测字符的方法吗?
最佳答案
根据 documentation 中的示例, cv2.findContours()
返回 3 个值,您必须声明变量以准确存储 3 个值。
See, there are three arguments in cv2.findContours() function, first one is source image, second is contour retrieval mode, third is contour approximation method. And it outputs the image, contours and hierarchy. contours is a Python list of all the contours in the image. Each individual contour is a Numpy array of (x,y) coordinates of boundary points of the object.
image,contours,hierarchy = cv2.findContours(imgBWcopy.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
关于python - 使用 cv2.findContours() OpenCV 时出现 ValueError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30423049/