1

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?

ZdaR
  • 22,343
  • 7
  • 66
  • 87
Arash Hatami
  • 5,297
  • 5
  • 39
  • 59

1 Answers1

2

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)
ZdaR
  • 22,343
  • 7
  • 66
  • 87
  • oh thank you that's work !!! now , how can i recognize the characters and put them to a string value ... like "756jwb" for exp @anmol_uppal – Arash Hatami May 24 '15 at 11:43
  • Didn't the answer linked in your question helped you ? – ZdaR May 24 '15 at 11:44
  • the title is 'segmenting' , but i can't find any way for this .... just converting picture with homomorphic or threshold @anmol_uppal – Arash Hatami May 24 '15 at 11:53
  • you will find a lot of useful information. http://stackoverflow.com/questions/4706118/read-numbers-and-letters-from-an-image-using-opencv – ZdaR May 24 '15 at 11:59
  • thanks but that is C Language :( ... i want python and opencv @anmol_uppal – Arash Hatami May 24 '15 at 12:07
  • I am sorry @ArashHatami But You will never get code just appropriate to you for such complicated problems, You will only get reference and then you need to work on it, Who knows you could be the first to implement this with Python. :D – ZdaR May 24 '15 at 12:12