LPR Walk Through / Tutorial

Here's a typical shot with the current camera / location. Anyone have thoughts on what I need to do for better APLR recognition?

5c90e875579bd0b9f7f4919082b1a080.jpg
 
1. I need more zoom than the Z5 is providing.

or

2. My capture angle is too steep

Thoughts from the pros?

Camera Placement Guide — openalpr 2.2.0 documentation

- Z5 has a 35mm lens - it should be more than adequate. Also why have you left it in black and white?
- Your first test photo that includes fire hydrant looks more in line with 30 degrees. What is your Z5 Exposure setting in this photo? It likely needs to be shorter i.e 1/1000.
 
Last edited:
Camera Placement Guide — openalpr 2.2.0 documentation

Also, what is your Z5 Exposure setting (night/day)?

I'm running 1/4000 shutter daytime and 1/2000 shutter night time. Exposure seems good. Plates are quite readable (human) day or night with little to no motion blur.

I believe the steep (~45 degree) read angle is my biggest issue.

To resolve that, I need more zoom. I have a z12 model on order.
 
What size is the lens on your Z5? And yes from what i see the angle is the most significant issue.

It's VF 7-35.

The Z12 is VF 5-60.

With the extra zoom, I should be able to shoot further down the street with less angle.
 
I'm running 1/4000 shutter daytime and 1/2000 shutter night time. Exposure seems good. Plates are quite readable (human) day or night with little to no motion blur.

I believe the steep (~45 degree) read angle is my biggest issue.

To resolve that, I need more zoom. I have a z12 model on order.



Yep. My experience is anything past about 25-30 degrees makes LPR very difficult. Straight on or as close to it will yield the best results.
 
How many feet approx. from camera to the car (in the still shot with the fire hydrant)?

See my below thread - specifically the snapshot of the fire engine - this is only a 25mm lens at approx. 100 feet and openalpr picks up pretty much every plate with this angle / lens.

Hikvision 2032i Lens Change
 
Well, I finally have LPR working!

Over the next few days, I’ll document the steps I took and what I ended up with (and what’s next) here.

For now, I settled on the Dahua z12 camera. I had to use max zoom and aim ~75 feet down the road to get usable captures.
 
So... my original thoughts when I opened this thread were:

1. Acquire a camera with adequate lens, resolution, and IR to observe plates day / night

2a. Configure (camera? Blue Iris?) such that snapshots are put into a directory for post processing

2b. Possible configuration of ALPR Daemon to monitor stream from camera

For my application, 2b seems the best, as it appears that the Daemon can be configured to send output via URL call; if so, that would be perfect for my perl scrip environment on apache I already have running

3. Take action via script on plates observed (enter into database, log to text file, etc.)

4. Trigger other actions on home automation server - my end goal would be to recognize "known" plates and make appropriate voice announcements on Home Automation system


Where I stand now:


1. After trying a Dahua IPC-HFW5431-Z5, I realized there were two issues for my application:

1. The zoom was not adequate to get a plate far enough away such that the angle to the plate was usable

2. The 4MP was not needed. ALPR can't process that much data fast enough.

I ordered and received a Dahua IPC-HFW5231-Z12.

This has enough zoom to get a tight crop of both lanes ~75 feet down the roadway.

I estimate I am at about a 20 degree angle of incidence to the plates.

I am using a script on my home automation PC to switch between day and night exposure, AND to set specific focus values ~40 seconds after the day / night toggle. Allowing the camera to auto-focus resulted in poor results, because the object chosen didn't always result in my plate zone being in focus. For the Z12, the script command to set focus is:

$zoom_focus_url ="{user}:$camera_data{pass}\@$camera_data{host}:$camera_data{port}/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=$camera_data{night_focus}&zoom=$camera_data{night_zoom}";
When you have the camera set the way you want it, you GET the correct values to use in this script from:

{host}:$camera_data{port}/cgi-bin/devVideoInput.cgi?action=getFocusStatus
Values will likely be different between day and night. I was not able to achieve good results without scripting specific focus values.

You MUST get your camera properly configured for exposure, shutter speed, focus and angle such that you and command line ALPR can get good results day and night before you will have success beyond this point.​
 
2a. Configure (camera? Blue Iris?) such that snapshots are put into a directory for post processing

2b. Possible configuration of ALPR Daemon to monitor stream from camera


I ended up going with option 2b.

There are plenty of tutorials out there on installing openalpr and openalprd, so I won't repeat those here. BUT I will share the critical configuration steps I found:

ALPR needs to be calibrated to your specific image geometry.

The command to do this is:

openalpr-utils-calibrate <filename>
The <filename> should be an actual capture from your camera in it's final position, focus, etc.

Once adjustments are complete, pressing 'o' will output the resulting prewarp parameter. This will need to be pasted into:

/etc/openalpr/openalpr.conf file in the correct placeholder. Example:

; Calibrating your camera improves detection accuracy in cases where vehicle plates are captured at a steep angle
; Use the openalpr-utils-calibrate utility to calibrate your fixed camera to adjust for an angle
; Once done, update the prewarp config with the values obtained from the tool

prewarp = planar,1280.000000,720.000000,-0.000000,0.000000,-0.260000,0.945000,1.000000,0.000000,0.000000​


Before configuring the daemon, make sure you can reliably use the openalpr command line on several of your images and get good results.

To set up the daemon (this will monitor a camera stream continuously and output plates that it sees):

Set up the /etc/openalpr/alprd.conf file. You must set a stream. mine is:

stream = rtsp://<username>:<password>@<camera IP>:<camera rtsp port>/cam/realmonitor?channel=1&subtype=2
You can verify successful connection to a stream via the daemon command line:

alprd -f​

You should see a message that a successful connection to the video stream was made.

Once that is successful, you are in the home stretch!!!

Other critical parameters to set up in the /etc/openalpr/alprd.conf file are store plates = 1 and store_plates_location = <directory with permissions open such that alpr can put files there> mine are:

; Determines whether images that contain plates should be stored to disk
store_plates = 1
store_plates_location = /var/www/LPR_images/​

Also, in order to process these images, you will need to have the daemon POST JSON data to a url at which you have a script ready to process it.

I used:

; upload address is the destination to POST to
upload_data = 1
upload_address = http://<IP address ofserver hosting your process script>/cgi-bin/process_alpr.pl


As a baby step, I started by just ensuring that the script would receive data and output that data to a file.


Once you get this far, you can do anything within your imagination and coding skills with the data!!!

You will now have:

1. A camera physically mounted to clearly view license plates and configured so that you can clearly read plates day and night

2. A server with openalpr and openalprd installed and configured

3. A server running a script that can catch and process JSON data that will be output by alprd
At this point, each plate passing should output a JSON file (via your script), and a jpeg snapshot (to the directory you configured).

The JSON file has the name and location of the jpeg file, and a TON of data regarding what plate number alprd believes it saw.

That's it for now!!! More to come.
 
@kevkmartin Would you mind sharing your day and night setting for your IPC-HFW5231-Z12? I just received mine a couple days ago and thought your setting might give me a head start. thanks.
 
I just installed my IPC-HFW5431-Z5 and so far its working well. Still need to fine tune my settings. Day time no issues on full auto. For night I tried the 1/2000 shutter speed and it seems to work well. Camera is at full zoom and pointing straight up the street. I am at the end of a culdesac.
 

Attachments

  • plate.jpg
    plate.jpg
    209.2 KB · Views: 464
  • day.jpg
    day.jpg
    1,017.2 KB · Views: 451
  • Like
Reactions: bigredfish
Hi
@kevkmartin
I'm following your tutorial and thanks for your explanation.
Is it possible to post your process_alpr.pl file ?
I'm stick on that part

Thanks again