I'm trying to implement a traffic sign recognizer with OpenCV and SURF method. My problem is that i get random results (sometimes really accurate, sometimes obviously wrong) and i cant undertsand why. Here is how i implemented the comparison :
- First i detect contours on my image
- Then on each contour, i use SURF to find out if a traffic sign is inside and which traffic sign
The contour detection works perfectly well : using a gaussain blur and canny edge i manage to find a contour similar to this one :
Then i extract the image corresponding to this contour and i compare this image to traffic signs template image such as these :
The cvExtractSURF returns 189 descriptors for the contour image. Then i use the naiveNearestNeighbor method to find out similarities between my contour image and each template image.
Here are my results :
6/189 for the first template (which is the one i'm expecting to find)
92/189 for the second template (which is obviously very different in every way to the contour image)
I really dont understand these results…
Here is the list of the steps i perform :
- Turn the contour image in grayscale
- Turn the template image in grayscale
- Equalize the histogram of the contour image (cvEqualizeHist)
- Resize the template image to make it match the contour image
- Blur the template image (cvSmooth)
- Blur the contour image (cvSmooth)
- Do a cvExtractSURF on the template image
- Do a cvExtractSURF on the contour image
- For each descriptor o the contour image i do a naiveNearestNeighbor
- I store the number of "good" points
To evaluate the similarity between the 2 images i use the ratio :
number of goog points / total number of descriptors
P.S: For information i followed this tutorial : http://www.emgu.com/wiki/index.php/Traffic_Sign_Detection_in_CSharp
And used the find_obj sample of OpenCV to adapt it in C.