Detect Vehicle License Plates in an Image in Python

Cloudmersive
2 min readFeb 11, 2022

--

By leveraging the Cloudmersive Image API in your project, a variety of useful image-recognition, processing & editing services are possible. Using the /image/recognize/detect-vehicle-license-plates iteration of this API, you can quickly identify the position, size and content of any license places in an image. It’s important to note that license plates should be within 15–20 degrees on-axis to the camera for this API to be successful. Additionally, there are three supported image formats: JPG, PNG, and BMP. Below, let’s look at how you can connect easily in Python using code from the Cloudmersive API Console.

You can begin by running the below Python SDK installation command:

pip install cloudmersive-image-api-client

Next, copy & paste the below code snippets to complete the API call function. In the second snippet, you’ll need to provide your Cloudmersive API key for authorization. If you don’t currently have a key, visit the Cloudmersive website and you can easily create a free account (which includes 800 monthly API calls) in just a few minutes.

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

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet