sepehr78
sepehr78

Reputation: 71

Detecting car plates at different ligthings

I am writing a program in Java that detects car plates directly from a camera feed. I use OpenCV to apply an adaptive threshold, find contours, and check each contour's dimensions to determine whether it is a plate. This works very well, but I have to manually change the C constant argument of the adaptiveThreshold method when doing the adaptive thresholding depending on the time of day. For example, If I use the same constant from daytime during nighttime, then the resulting binary image has no white portions so no contours are detected. I was wondering if there is a way to somehow determine the C constant based on the brightness and/or contrast so that when the threshold is applied, the plates are detected as contours in any ligthing. I can post the code if it would help.

Thanks in advance.

Upvotes: 1

Views: 128

Answers (1)

Turing85
Turing85

Reputation: 20185

If you know how many white pixels you expect compared to black pixels, you can calculate the threshold dynamically. Lets, for example, say that you expect the binary image to be 80% white and 20% black. You can then calculate a threshold, so that those conditions are satisfied.

Another approach would be to empirically change the threshold as time changes. This would at least require that your system has access to the time, preferably even the date.

Upvotes: 2

Related Questions