How to detect vehicle license plates in photos in Node.js

For this task, we want to be able to automatically detect the location and inscription on a vehicle license plate, for example in this photo:

Image for post
Image for post

The first step is to add a reference to the library we need:

"dependencies": {
"cloudmersive-image-api-client": "^1.1.4"

Now, all we need to do is call the recognizeDetectVehicleLicensePlates method:

var CloudmersiveImageApiClient = require('cloudmersive-image-api-client');
var defaultClient = CloudmersiveImageApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveImageApiClient.RecognizeApi();var imageFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.var callback = function(error, data, response) {
if (error) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.recognizeDetectVehicleLicensePlates(imageFile, callback);

And this will give us our desired output:

"Successful": true,
"DetectedLicensePlates": [
"LocationX": 290,
"LocationY": 341,
"Width": 186,
"Height": 81,
"LicensePlateText_BestMatch": "0MG77",
"LicensePlateText_RunnerUp": "B0MG77",
"LicensePlateRecognitionConfidenceLevel": 0.849610595703125
"DetectedLicensePlateCount": 1

That’s all there is to it. No we can process license plates easily.

Written by

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