If you are blessed enough to have a $x,xxx license-plate-reading (LPR) camera like this, you might want to log those license plates. Streamie can help with that! New in v4.5.0, you can easily integrate a backend license plate logging mechanism with Streamie in minutes.
The key components to this solution are Cloudflare Workers + KV and Streamie Functions. The only requirement is that your LPR camera emits license plate events via ONVIF (as the above-linked LTS / Hikvision camera does).
When we’re done, we’ll have a simple API that will list all of the license plates that have been logged. This serves only as a starting point for a useful system. A complete solution would include an intuitive interface for searching, paging, managing, etc. The solution in this article is just a proof of concept.
To get started, create a new Cloudflare KV namespace. For this example I used “PLATES_KV”. Use whatever you want.
Next, create a Cloudflare Worker, and bind it to the KV namespace you just created. You should be able to accomplish everything in this article from your web browser without installing anything on your computer. Don’t get side-tracked by Wrangler and all manner of local development environments.
Once your Worker is created, edit the code for it. The following is a screenshot of the simple implementation of a /log and /list API call. The former will be used by the Streamie Function for logging license plate events. The latter can be used to list the logged license plates. View the JavaScript source code here.
Next, let’s create a Function in Streamie that will use our Cloudflare Worker API to log license plates. Navigate to in Streamie to Home — Functions — Options — Add Function, and choose “JavaScript”.
Update your Function with your name and some documentation. You’ll thank yourself later when you’re trying to understand how this works, or what it does.
Edit the source code for the Function. We only need a few lines of code to make this API call. You can view that code here.
The LTS cameras used in this example use “PlateNumber” when emitting an ONVIF license plate event. Your camera might be different. You’ll need to adjust this source code accordingly.
Use the Options button and save your source code. Don’t forget to use the Save & Close button when you’re done editing your Function.
Finally, edit your LPR camera in Streamie. Assuming your camera has seen at least one license plate while running Streamie, you should be able to “+ Add Action” and select the license plate event. You can find a tutorial on ONVIF events here. You’ll choose the “Run Function” event type, select the Function you just created, choose the member device that you want to do all of the work (this’ll be the Streamie device that actually streams the LPR camera), save your action, and save the changes to the camera. Then just stream your camera and wait for license plates to drive by.
For testing purposes I sometimes also add a “Speak Text” action that’s otherwise identical, so that I get an audible alert when the desired event occurs, and I know to check KV for the new data.
Using Functions, we’ve quickly extended Streamie to incorporate an external API, linking your camera with your backend system in just a few minutes.
Created: 1 month ago
Updated: 1 month ago
Author: Curtis Jones
Topics: Functions Tutorial ONVIF
Streamie provides a best-in-class user experience on your iPhone, iPad, Apple TV and Apple Silicon Mac, with an intuitive user interface that makes it simple to discover, stream, record, monitor and share your HomeKit, Google Nest, Ubiquiti UniFi Protect and ONVIF-compatible IP and RTSP cameras. Streamie keeps you informed with motion event notifications and it works with most cameras using its advanced audio and video codec support. You can watch your cameras from anywhere, record 24/7 to your private NAS, remotely manage multiple locations, device permissions and seamlessly synchronize settings across your devices; configure Hubitat smart home automations, live stream to YouTube and rely on the in-app technical support system when you need help -- and you can also reach us by phone. Download Streamie today for all of your CCTV needs.