LPR Camera API for Software Development Integration and Apps

Viewtron LPR cameras have an API interface for software developers to create custom home automations, access control system integrations, and 3rd party applications development. The LPR camera API posts an XML document to a server’s webhook endpoint that you specify in the camera’s firmware settings, which are accessed via a web browser interface. Watch the above video to learn how to setup the LPR camera and see how it interacts with the API server when a license plate recognition event occurs.


Open Source Viewtron IP Camera API Server

You can download the Python API server from Github on this page. There are also step instructions on that page on how to install the server on your Linux box.
https://github.com/mikehaldas/IP-Camera-API


Viewtron LPR Camera

ANPR LPR Camera

This is the Viewtron LPR-IP4 camera that I used in my demo. IT has been thoroughly tested with it. The camera is connected to a PoE switch and located on the same network as the Raspberry Pi computer where I installed the Python API server. Please note that you can send the API posts remotely over the Internet too.


License Plate Detection Configuration

Here are the steps I took to configure the LPR camera.

IP Camera Login

Log into the camera by going to it’s IP address in a web browser.

configure LPR Camera

Click on the Config tab in the upper right, then click on the License Plate Detection link.

enable license plate detection

On the License Plate Detection screen, do the following.

  1. Check Enable.
  2. Click on the Draw Area Button
  3. Draw the license plate detection zone.
  4. Click on the Draw Target Size button in area (2) then enter the min and max sizes for plates. These do not need to be exact.

Click Save when done.

IP Camera HTTP Post

Next, click on the Network link on the left. Then, click on the HTTP POST link.

http post server add

On the HTTP Post screen, click on the Edit button.

http post API server settings

Next, click on the Add button. Then fill in the API server’s IP address, port,  and path. You can also check off the type of alarms and data that you want the server to send. IN my testing, I only wanted to send LPR events, so I only checked License Plate Detection in the Smart Alarm Type section. In the Smart Alarm Data, I checked all pictures and options.

When done, click the Save button.


License Plate Database Setup (optional)

This section is optional. If you want to use the LPR cameras built-in database to manage a list of “Authorized Plates”, this is how you set that up. if you do not setup a list of authorized license plates in the database, the camera still sends all of the other data in the XML post except the authorization info.

camera license plate database

To add plates to the license plate database, click on the License Plate Detection link on the left. Then, click on the Add button. Please note that you can also click on the Bulk Entry button if you want to upload a large list of license plates using a CSV file.

add license plate database

On the vehicle Information screen, enter the License plate number and select “Allow list” from the list type dropdown if you want this to be an authorized plate. The rest of the information is optional. Click Save when done. Repeat this process for each license plate that you want to add to the database or use the Bulk Entry to upload a CSV list of plates.


Installing the API Server

The open source API server is written in Python. It consists of two main files.

  • server.py – the main web server program
  • viewtron.py – a library class that handles all of the XML parsing from the IP camera. Basically, a data abstraction layer.

I developed the server on a Ubuntu computer and have also tested it on a Raspberry Pi. It should work well on any Linux based operating system. I documented the setup instructions here on Github.


API Server Output

Here is a screenshot of what the typical output looks like when the API server is running and receiving HTTP Posts from an LPR camera.

LPR API Server

On the above screenshot, you can see the following print outputs from the server.

  • Server startup command / initial output from the startup.
  • License Plate Detection event notes whether the plate is authorized or not, then saves the images of the plate and logs the event to the CSV file.
  • “Keep-alive” posts are periodically sent by the camera to make sure the server is still ready to receive posts.

License Plate Image Snapshots Sent by API

lpr snapshot image overview

Here overview snapshot image that the camera sends in the XML payload when a license plate detection event occurs..

lpr snapshot image target

Here is the cropped target image that the camera sends in the XML payload when a license plate detection event occurs.


Complete License Plate Recognition Camera Systems

viewtron LPR camera system

Most of our customers use Viewtron LPR cameras with a Viewtron NVR and one or more overview cameras. This provides a complete LPR solution for home, business, and government installations. The team at CCTV Camera Pros has designed thousands of custom systems for customers all of the world. However, some of our customers have the need to integrate the license plate recognition functionality of just the Viewtron LPR camera with a 3rd party application. That is why we provide the API that was documented in this article.


Viewtron License Plate Recognition Video Demos

LPR Camera Videos

You can watch additional Viewtron license plate recognition video demos here.


Have Questions / Need Help?

If you have any questions about LPR camera applications or general questions about security camera system, please email me anytime at mike@cctvcamerapros.net.