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

Cloudmersive
1 min readMay 27, 2019

--

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:

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) {
console.error(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.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet