liceHow to detect vehicle license plates in photos in Java

License plate recognition has a plethora of useful applications, but is usually locked behind the steep challenge of setting up a photo processing AI and then training it. Today, we will be skipping this difficult and time-consuming process, and should have our license plate recognition ready to go in just a few minutes using just a little Java and an API.

First we need to add references to Maven POM so that we can dynamically compile our library using Jitpack.

Repository Reference:


Dependency Reference:


Now we call recognizeDetectVehicleLicensePlates, and let our API go to work for us.

// Import classes://import com.cloudmersive.client.invoker.ApiClient;//import com.cloudmersive.client.invoker.ApiException;//import com.cloudmersive.client.invoker.Configuration;//import com.cloudmersive.client.invoker.auth.*;//import com.cloudmersive.client.RecognizeApi;ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");Apikey.setApiKey("YOUR API KEY");// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.setApiKeyPrefix("Token");RecognizeApi apiInstance = new RecognizeApi();File imageFile = new File("/path/to/file"); // File | Image file to perform the operation on.  Common file formats such as PNG, JPEG are supported.try {VehicleLicensePlateDetectionResult result = apiInstance.recognizeDetectVehicleLicensePlates(imageFile);System.out.println(result);} catch (ApiException e) {System.err.println("Exception when calling RecognizeApi#recognizeDetectVehicleLicensePlates");e.printStackTrace();}

And it’s really just as simple as that. Our response will be given in this format:

"Successful": true,
"DetectedLicensePlates": [
"LicensePlateText_BestMatch": "string",
"LicensePlateText_RunnerUp": "string",
"LocationX": 0,
"LocationY": 0,
"Width": 0,
"Height": 0,
"LicensePlateRecognitionConfidenceLevel": 0
"DetectedLicensePlateCount": 0
Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store