DEV Community

loading...
Cover image for Extending License Plate Extraction
Mindee

Extending License Plate Extraction

dougsillars profile image Doug Sillars Originally published at mindee.com ・6 min read

If you’re like me, you’ve gotten a speeding ticket.  Even more like me, it was a speeding ticket…from a camera. My last ticket was in Dresden. I was crossing a bridge over the Elbe, and the signs all of a sudden said 50 km/hr.. And I was…. Well I was going over that.  A few weeks later, a ticket arrived in our mailbox.  

 

The ticket had a photo of my car (with me driving).  You could see our license plate, but to show that there was no possibility of mistake, they also gave a closeup of our plate.  With the details from my UK plates, they were able to look up my address and assign the ticket to me.

 

How did they scan the image for a license plate?  Likely using an OCR or machine learning API like Mindee’s License plate API.  When this API is provided a photo of a car (where the license plates are visible), it will find the region of the plate, and extract the details form that part of the plate.

 

For example, when I submit this image (from Google Image search)

I received the response “LR33TEE’.  Read all about how to use our License plate API in our tutorial.

 

What can I to with the license tag information

 

Governments are able to identify us based on our plate.  But what data can we extract from license plates?  I know that in some countries, like Ireland and Germany, you can identify the region of the car’s origin from the letters on the plate.  BUt I want more information.

 

But can we learn more?  The UK government has a free API through the DVLA that uses the license plate number and provide information about the vehicle:


The call (using Axios in Node) looks like this:
 

  config: {

    url: 'https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles',

    method: 'post',

    data: '{"registrationNumber":"LR33TEE"}',

    headers: {

      Accept: 'application/json, text/plain, */*',

      'Content-Type': 'application/json',

      'x-api-key': <API TOKEN>',

      'User-Agent': 'axios/0.20.0',

      'Content-Length': 32

 

Now, it turns out, "LR33TEE" is not in the DVLA database. It's probably a fake reg tag Photoshopped for the article.  So, we'll try again:

 

 

When you call this API, the response looks like this:

DVLA response {
  registrationNumber: 'S638GWH',
  engineCapacity: 1396,
  markedForExport: false,
  fuelType: 'PETROL',
  motStatus: 'Not valid',
  colour: 'SILVER',
  make: 'HONDA',
  yearOfManufacture: 1999,
  taxDueDate: '2016-11-04',
  taxStatus: 'Untaxed',
  dateOfLastV5CIssued: '2015-02-23',
  motExpiryDate: '2016-12-15',
  wheelplan: '2 AXLE RIGID BODY',
  monthOfFirstRegistration: '1999-01'

Now, this image is from an article with CCTV camera footage about a person stealing petrol.  It is an older article, and as you can see - an older car, that is no longer taxed or has a valid MOT - probably in a junkyard somewhere.

What can we do with this data?  For me, this is great, I can never remember when my MOT is due, or when I need to retax my car.  Now I can use this API to quickly look up my car - just by knowing the numbers on my license plate. (They have a website where you can type this in).

 

But it can be easier!

Combining DVLA and Mindee’s License plate API, I can submit a photo of a vehicle, and it will extract the registration number automatically.  Then this text string can be sent to the DVLA for a response.

I’ve built a super simple demo - use your phone to take a photo of a car with a UK license plate, and you can know the MOT date:

https://demo-license-plates.mindee.com/MOT

Want to know when your tax is due?

https://demo-license-plates.mindee.com/TAX

will tell you when your taxes need to be renewed. 

Finally, https://demo-license-plates.mindee.com/CAMERA will give you the full output from the DVLA API.

Watch a video on how this magic works:

Want to try out the code?  It's available on Github.

 

Going Further

What else could the combination of Mindee with DVLA information be used for?  Thinking about the CCTV image at the petrol station.  What if the API looked up the car for everyone pumping gas.  The API contains the type of fuel for the vehicle.  According to insurance estimates, over 150,000 vehicles in the UK accidentally pump the incorrect fuel into their gas tank.  By taking a photo with the CCTV, the station can know what type of fuel should be used, and can stop the pump if the incorrect fuel line is connected.

 

Again - thinking of the image above: perhaps cars with expired tax and MOT are more likely to not pay for petrol, so these cars could be given a lower volume of petrol as a prepay.

 

Finally, if the station is also a service station - the receipt could also print a coupon for MOT service -reminding the customer that their MOT expires in 3 months.. 2 months.. 1 month, and give an appropriate discount for scheduling their service early.

 

Conclusion

 

The Mindee License plate API is both elegant and simple.  You get useful information (the license plate number) just from a photo.  Automatic parsing of a photo for this information now opens up a gateway of new opportunities. Now you can use additional APIs to probe for more information about a specific car or truck.

 

Discussion (0)

pic
Editor guide