Reputation: 5571
I want to detect the characters of car's license plate. I saw this post yesterday, but when I run the program I get this error:
contours,hierarchy = cv2.findContours(imgBWcopy.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack"
Why? Does anybody have different way to detect characters?
Upvotes: 1
Views: 4457
Reputation: 22964
As per the examples in the documentation, cv2.findContours()
returns 3 values and you must declare variables to store exactly 3 values.
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)
Upvotes: 2