Taseer Ahmed
Taseer Ahmed

Reputation: 159

OpenCV Python Car Number Plate Detection

I am working on License Plate Detection using HoG. I am now in the testing phase. When I use

hog.detectmultiscale()

to localize the number plate, I get just a single rectangle false positive localization. In addition the above function also returns the same set of points for all images I test on. These set of points are always multiples of the winstride I use for calculating the HoG features.

Below is the code:

hog = cv2.HOGDescriptor((64,64), (16,16), (8,8), (8,8), 9)
svm = cv2.SVM()
svm.load('trained.xml')
img = cv2.imread('6.png', cv2.IMREAD_COLOR)
h = hog.compute(img) 
p = svm.predict(h)
print p

model = pickle.load(open("svm.pickle"))
hog.setSVMDetector(np.array(model)) 
rects, weights= hog.detectMultiScale(img, 1.5, (7,7),(10,10), 1,1)  

for (x, y, w, h) in rects:
   cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
   print x,y,w,h

cv2.imshow('plate', img)
cv2.waitKey(0) 
cv2.destroyAllWindows()

Can you please tell me how to localize the plate correctly ?

Here is a snapshot of the result:

enter image description here

Upvotes: 3

Views: 4882

Answers (1)

Fansi Kong
Fansi Kong

Reputation: 11

I think what Billal talked is right, espeaically the first point. In your case, the detector size of HOG is 64*64(hog = cv2.HOGDescriptor((64,64), (16,16), (8,8), (8,8), 9)). It only can find the subimages of the same or proximate length-width ratio. You should change the window size both in you detector and training. The proper ratio should be 1:4(depend on you images). I am focusing on this recently and I used thousands images, but it seems result is not good too, only 50% success rate, maybe you should try other descriptor.

Upvotes: 1

Related Questions