Full ALPR Database System for Blue Iris!

And yet one more request for help. I've got a list of plates and images that I would like to bring into the ALPR database. I'm trying to write a python program to call the API, but I'm apparently not clear on the format. Here's what I tried and got a 500 error.
import urllib.parse
import urllib.request

url = ""
header={"x-api-key" : 'a7f1bc2f790dfc6959...(redacted)...'}
post_param = urllib.parse.urlencode({
'plate_number' : '9MQC052',
'Image' : 'Alerts/Cam3a.20240611_123315_45027682.jpg',
'Camera' : 'LPR',
'timestamp' : '2024-06-11T19:33:17Z'
}).encode('UTF-8')

req = urllib.request.Request(url, post_param, header)
response = urllib.request.urlopen(req)

print(response.read())
Try this

Python:
import requests
import base64
from datetime import datetime, timezone

# File path for the image
image_file_path = 'test.jpg'

try:
    # Open the image file in binary mode and encode it as Base64
    with open(image_file_path, 'rb') as image_file:
        encoded_image = base64.b64encode(image_file.read()).decode('utf-8')

    # Define the URL and headers
    url = "http://192.168.1.21:3000/api/plate-reads"
    headers = {
        "x-api-key": "a7f1bc2f790dfc6959...(redacted)...",
        "Content-Type": "application/json",
    }

    # Create the JSON payload
    payload = {
        "plate_number": "9MQC052",
        "Camera": "LPR",
        "timestamp": datetime.now(timezone.utc).isoformat(),  # Use timezone-aware datetime
        "Image": encoded_image
    }

    # Send the POST request
    response = requests.post(url, headers=headers, json=payload)

    # Check the response
    print(response.status_code)
    print(response.text)

except FileNotFoundError:
    print(f"The file '{image_file_path}' does not exist.")
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")
 
Thanks @MikeLud1, that did the trick! It also made me realize why nothing was going into the database previously because I only changed the default database password in one place and it looks like it needs to be changed in two places during setup. Do you know of an easy way to get into the database container to change the password?

@algertc, I'm noticing that when I manually call the API passing older plate sightings, it correctly stores the last seen date as the timestamp passed in, but it puts the current timestamp as the first seen date. Is it possible to fix this?
 

Attachments

  • Screenshot 2025-01-01 174752.png
    Screenshot 2025-01-01 174752.png
    21.4 KB · Views: 14
I have not tried to install this yet, just read over the thread - sounds cool.

I would love to see the ability to recognize the make/model of vehicles. I can certainly contribute to help train a model.

I capture about 5,000 plates a day currently, many I capture both the front and back plate. I keep images for about 6 months, or as my 1tb of storage allows.

Because I capture both the front and rear of vehicles, I use the data from both images to try and auto-correct incorrect plate matches.


Reading the tire pressure information of passing vehicles is super nerdy, I love it!!

View attachment 210818View attachment 210819
Thanks for your interest.

I would like make/model analysis as well, but that is something that should happen in CPAI. Many users have said they didn't have great results with that model so improvement in that area would be great.
 
Just popping around some pages of the thread, so this may be covered and resolved already.

Ideally exporting a CSV file as an option. No images, but how many times would one encounter the same plate number from two states in one area?
Customizable fields would be a bonus, but unneeded columns can be remover by end user.
It keeps a searchable record for going further back.
Less tech savvy people can still write fairly advanced scripts in Excel to search and sort in it; or just use the basic sort options.

Very good point for the excel users.
 
I've just got around to installing this on the Blue Iris machine. I installed Docker Desktop for Windows as recommended, did all the steps and it was up and running. Overnight, the box rebooted for some reason, but the Docker Desktop (and hence the ALPR Database container) did not restart. My question is, what does one need to do so the engine is running on a Windows 10 machine. I saw responses saying to create a startup task in Task Scheduler but apparently that doesn't work anymore.

Help!?

There should be a start on boot option in the settings if you have docker desktop.
 
There should be a start on boot option in the settings if you have docker desktop.
I'll check again but I think that only works after one logs in rather than running without someone logging in.

Anyone else running it on the same Windows machine as BI?
 
Unfortunately that only changes the password that is sent to the database, not what the database expects. That's how I was able to get it working by sending the default 'password' but I'd rather change it to something that's not the default.

You can do it by editing the postgres user with a query or with the CLI. You can connect under the exec tab of the container in docker desktop.


Bash:
sudo -u postgres psql
\password postgres

Enter password and new password and you should be good.

@algertc, I'm noticing that when I manually call the API passing older plate sightings, it correctly stores the last seen date as the timestamp passed in, but it puts the current timestamp as the first seen date. Is it possible to fix this?

This is by design because the database automatically sets the timestamp when that record is received. As far as the database is concerned, that is the first seen date. To achieve the behavior you are looking for, it would need to go check all the records and compute this or let the user send it manually. I don't think either of these make sense to do for the majority of users, since you will only encounter this trying to bulk upload plates programmatically. What I would recommend is just adding something to your script to update the column in the database after it is set.
 
I'll check again but I think that only works after one logs in rather than running without someone logging in.

Anyone else running it on the same Windows machine as BI?

Hmm, I think you're right. I don't really use or know much about Windows, but IIRC, the way that works is by just copying the executable to some directory which is then started by your user.

Maybe look at adding it as a service with NSSM
 
Hmm, I think you're right. I don't really use or know much about Windows, but IIRC, the way that works is by just copying the executable to some directory which is then started by your user.

Maybe look at adding it as a service with NSSM
That's a good idea. I used that for another app that wasn't a service.
 
Hmm, I think you're right. I don't really use or know much about Windows, but IIRC, the way that works is by just copying the executable to some directory which is then started by your user.

Maybe look at adding it as a service with NSSM
Unfortunately NSSM didn't work. It would not start as a service. I've set it to start at login and I'll just have to monitor if the machine shuts down abnormally so I can manually log it in. I'm curious if others are trying to run it on their Blue Iris (Windows) machine, or is everyone doing it on a separate Linux box?
 
Unfortunately NSSM didn't work. It would not start as a service. I've set it to start at login and I'll just have to monitor if the machine shuts down abnormally so I can manually log it in. I'm curious if others are trying to run it on their Blue Iris (Windows) machine, or is everyone doing it on a separate Linux box?
It’s a bit jank, but the way I run blue Iris is by setting the PC to auto log in with a non windows account. I believe I had to add something to the registry and change some things in the account settings. I have the machine set to boot on power in BIOS.

I’d try and go for that and see what happens
 
  • Like
Reactions: Skinny1
Feature requests:

DASHBOARD:
  1. Top 5 Plates - show latest image, tag and note. Make plate clickable.
  2. Time Distribution - make column bar clickable to show the plates in that hour?
  3. Make items at top middle of dashboard clickable or expandable for list of total plates, total reads, unique plates, weekly unique.
LIVE VIEW:
  1. Allow sorting of columns
  2. Allow a choice of 'No tag' for filtering to those without a tag.
DATABASE:
  1. Allow a choice of 'No tag' for filtering to those without a tag.
  2. On 'Tags' tab, allow editing of the text and the color.
INSIGHTS:
  1. Could the button for View All be closer to the top? Or perhaps make the plate name at the top clickable?
KNOWN or SUSPICIOUS plates:
  1. Make plate name clickable.
  2. Add sorting
NOTIFICATIONS:
It only seems possible send notifications for plates that you designate by name in advance.
  1. Is it possible to make these based on rules such as the sighting of a suspicious vehicle, an untagged vehicle, an unknown vehicle, a vehicle newly added to the database, at a certain range of time (say 10pm to 5am), etc.?

Update: Removed requests that are already implemented
 
Last edited:
  • Like
Reactions: MikeLud1
Nice update available:
  • Time format fix
  • Dashboard Redux: adjustable period, new visuals, top plates improvements, better responsiveness, clickable bars on chart, hover for quick look.
  • Ignore flag for known plates (Eyeball in known plates page)
  • Live feed can now actually be live updated. Switchable with toggle. Your page and scroll position are maintained on receipt of a new plate.
  • Ability to edit tag name and color
  • Sensible default sorting of database
  • Speed and loading improvements

I would definitely like to do more advanced notification rules. Sorting on live feed page will come next. I will add the untagged filter also @VideoDad

Pics below. I thought the hover for quick look thing was pretty cool.

Dashboard_SS.png

Dashboard_SS2.png