How to detect vehicle license plates in photos in Python

First install the client using pip installer:

pip install git+

Next call recognize_detect_vehicle_license_plates:

from __future__ import print_function
import time
import cloudmersive_image_api_client
from import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_image_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Apikey'] = 'Bearer'
# create an instance of the API class
api_instance = cloudmersive_image_api_client.RecognizeApi(cloudmersive_image_api_client.ApiClient(configuration))
image_file = '/path/to/file' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
# Detect vehicle license plates in an image
api_response = api_instance.recognize_detect_vehicle_license_plates(image_file)
except ApiException as e:
print("Exception when calling RecognizeApi->recognize_detect_vehicle_license_plates: %s\n" % e)

Here is a quick example image and output:

"Successful": true,
"DetectedLicensePlates": [
"LocationX": 638,
"LocationY": 770,
"Width": 128,
"Height": 62,
"LicensePlateText_BestMatch": "G402205",
"LicensePlateText_RunnerUp": "G40ZZ05",
"LicensePlateRecognitionConfidenceLevel": 0.8761985778808594
"DetectedLicensePlateCount": 1

As you can see, we are provided with the number of total license plates, a best guess and second guess of the license plate string, it’s location and dimensions, and a confidence rating of the text recognition.

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