Replies: 15 comments 59 replies
-
Thank you for sharing. How do I get this to work without Frigate+? |
Beta Was this translation helpful? Give feedback.
-
I'm doing a similar function using a local instance of ALPR Snapshot from Plate Recognizer, together with the Plate Recognizer HA integration. It's working perfectly and was pretty simple to set up. It's also possible to use their free cloud-based product for up to 2500 detections a month. Local is much faster if you have a good machine with an Nvidia GPU as well as being more private, of course. In short, I set up a zone on a Frigate camera and when a car is detected in that zone, an automation is triggered and one frame is sent to ALPR Snapshot via the HA integration. That then triggers an HA event if a plate is detected. If the license plate is our car's and our gate is closed or closing, then open the gate. configuration.yaml: image_processing:
- platform: platerecognizer
api_token: xxxx
server: http://192.168.x.x:8080/v1/plate-reader/
regions:
- gb
watched_plates:
- ab12cde
detection_rule: strict
region: strict
source:
- entity_id: camera.gate # Supplied by Frigate integration automation: alias: Open gate when our car detected in driveway
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.plate_car_occupancy # Provided by Frigate integration, state changes to 'on' when a car is detected in the 'plate' zone.
to: "on"
condition: []
action:
- service: image_processing.scan
data: {}
target:
entity_id: image_processing.platerecognizer_gate
- wait_for_trigger:
- platform: event
event_type: platerecognizer.vehicle_detected
event_data:
plate: aa12cde # Plate to check for
timeout:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0
continue_on_timeout: false
- condition: state
entity_id: cover.gate
state:
- closed
- closing
- service: cover.open_cover
data: {}
target:
entity_id: cover.gate
mode: single
docker-compose.yaml for ALPR Snapshot version: "3.8"
services:
alpr-snapshot:
container_name: alpr-snapshot
restart: unless-stopped
image: platerecognizer/alpr-gpu
environment:
- LICENSE_KEY=xxxxx
- TOKEN=xxxxx
- WORKERS=8 # Adjust based on number of CPU cores. See docs.
volumes:
- ./alpr-snapshot/license:/license
ports:
- "192.168.x.x:8080:8080/tcp"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu] Frigate config: cameras:
gate:
ffmpeg:
output_args:
record: preset-record-generic-audio-copy
inputs:
- path: rtsp://127.0.0.1:8554/gate # go2rtc
input_args: preset-rtsp-restream-low-latency
roles:
- record
- detect
motion:
mask:
- 1920,0,1920,406,1138,381,824,412,0,464,0,0
zones:
plate:
coordinates: 1316,714,589,711,424,1080,1534,1080 |
Beta Was this translation helpful? Give feedback.
-
@NickM-27 How to get found vehicles names back in home assistant? |
Beta Was this translation helpful? Give feedback.
-
Hey Nick, FYI line 34 in the python script has an indentation issue; it's copying over with 2 tabs instead of 8 spaces. |
Beta Was this translation helpful? Give feedback.
-
@NickM-27 since updating frigate to beta3 there is now a lot of events for plate recognition. Some times a few per socond. Even where there is no motion, only one stationary car. It looks like it has someting to do with new stationary object detection enchantments.
|
Beta Was this translation helpful? Give feedback.
-
Good morning @NickM-27, thanks again for sharing this solution; it's performing better than I what I could build in nodered. I'm curious about lines 42 to 45 of the script where x_mid is defined but then y_max is defined and not used. Following the same logic as x_mid, I created y_mid and then used it in the img.crop function and it seems to be working. Is there something I'm not thinking through about the design? |
Beta Was this translation helpful? Give feedback.
-
@NickM-27 thank you for all of your hard work on Frigate. I just launched my first custom model using Frigate+ and now I want to do license plate detection. Very exciting! My issue is that I have tuned my LPR cameras to clearly read license plates at night, which basically blacks out the entire image besides the license plate and maybe the tail lights. There is no image of a vehicle for Frigate to detect. Does anyone know how to trigger the license plate reading process if a vehicle cannot be seen in the image? |
Beta Was this translation helpful? Give feedback.
-
Deara all, I am also trying to install this stuff but it fails to install the license plate recognizer in openpjojectai home asistant addon. this is my log:
Seems hanging somehow.. any idea? Would love getting this ruunning as local ALPR does not work for home asistant OS. |
Beta Was this translation helpful? Give feedback.
-
Someone created a docker based project you can just tie into MQTT rather than even relying on Home Assistant and it seems pretty reliable. https://github.com/ljmerza/frigate_plate_recognizer |
Beta Was this translation helpful? Give feedback.
-
I have Frigate working and detecting cars and people. I'm trying to get license_plate working. It seems like if I use Frigate+ there are already trained models for this object type? Or will I need to train my own? I don't quite understand how to stand up Frigate+ as opposed to Frigate. Is that just installing the beta? I'm happy to pay for training and development. I was just hoping not to have to train (annotate and send images) etc. Thanks in advance for any words of wisdom you might have. |
Beta Was this translation helpful? Give feedback.
-
@NickM-27 If I have snapshot height set to 270 will that negatively affect OCR on the plates because the image is so small? Is it better to not set height or set it to full size of camera? |
Beta Was this translation helpful? Give feedback.
-
Codeproject.AI appears to send the images through Yolov5 to detect a license plate and then goes on to OCR it and Yolo isn't finding license plates a lot of the times even when there are good license plates that were found by Frigate. |
Beta Was this translation helpful? Give feedback.
-
Hello! Is this script still accurate? I can see it's all working but no sub label is placed on Frigate (Beta 4) Ta! |
Beta Was this translation helpful? Give feedback.
-
Can I use this project to capture all license plates, not just 'watched' plates? I would like to capture all vehicles and update a google sheet with the plate read for an upcoming event I have. I plan on using a RPI 4 and Reolink 820a camera at the event gate house, which would have internet connectivity if required, otherwise the two devices would be on a local switch. |
Beta Was this translation helpful? Give feedback.
-
@NickM-27 does this still work fine with 0.15? or should I just wait for 0.16 |
Beta Was this translation helpful? Give feedback.
-
I spent quite a while trying different ideas to get a working & fully local license plate setup and I am quite happy with this one so I am sharing a guide on how to do this.
Prerequisites
Preliminary Info
The approach in this guide requires using a python script to run some of the logic because it would be much more difficult to do in a Home Assistant automation. This script is called directly from home assistant.
Python Script
/config
directory. For this guide I will call mine/config/bashscript
license_plate.py
in/config/bashscript
The contents of the file should be
There are a few things to note here:
detected_plates.log
which will provide info on what plates are detected and if it matches a known plate/config/bashscript/crop.jpg
Home Assistant Configuration
The next step is adding this python script to the Home Assistant
configuration.yaml
file. This is done via theshell_command
type:Home Assistant Automation
The final step is setting up the Home Assistant automation, this will run on a car event only when it has a license plate attribute detected. It will then run 3 iterations of checking for the license plate and stop when a license plate is detected.
This single automation will run on all cameras that detect a car with a license plate in the zones defined, so if you have a driveway zone specified for the garage and driveway camera it will run on both.
Beta Was this translation helpful? Give feedback.
All reactions