Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
how to install camera support for OpenALPR on a raspberry pi
This is a scratchpad for now.
please do not use it for anything...
Status a/o 2016 01 14: alprd will not connect to the mjpeg stream as configured using this tutorial. not sure why.
according to this: https://groups.google.com/forum/#!topic/openalpr/oGgXBGCRYws you need to compile opencv with support
for libavcodec-dev, libavformat-dev, and libswscale-dev . previous tutorial does not include this and may break when
these are included. going back to test.
Assumes you have traversed https://gist.github.com/amstanley/9da7febc9a3e3c2228ee and installed openALPR on your PI
Back up your Pi to an image so if you screw it up somehow you can reset to a known point without having to recompile everything:
diskutil list
pick the correct disk to back up. in my case it is /dev/disk2. note that in the command you will refer to this as /dev/rdisk2.
sudo dd if=/dev/rdisk2 bs=1m | gzip > /path/to/backup.gz
to restore:
unmount the disk:
diskutil unmountDisk /dev/disk2
then restore the image:
gzip -dc /path/to/backup.gz | sudo dd of=/dev/rdisk2 bs=1m
follow the instructions on the raspberry Pi camera box to physically install the camera
when you power up, you will need to enter setup and enable camera support:
sudo raspi-config
scroll down to enable camera support and press <enter>, follow the prompts to enable, and then reboot the pi
test camera support by taking a picture:
raspistill -p 100,100,400,400
Set Up the camera to stream mjpeg. to do this follow this tutorial exactly:
http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14
the steps are:
curl http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc | sudo apt-key add -
Add the following line to the file /etc/apt/sources.list :
deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main <- SHOULD THAT BE JESSIE?
sudo apt-get update
sudo apt-get install uv4l uv4l-raspicam
sudo apt-get install uv4l-raspicam-extras
sudo apt-get install uv4l-server
sudo apt-get install uv4l-mjpegstream
restart:
shutdown -r now
test the uv4l server by going to http://127.0.0.1:8080/stream/video.mjpeg in the web browser.
edit the alprd daemon config:
cd /etc/openalpr
sudo nano alprd.conf
below the line that says '[daemon]' add or edit the foloowing lines to look like this:
; country determines the training dataset used for recognizing plates. Valid values are us, eu
country = us
; text name identifier for this location
site_id = raspberry_pi
; Declare each stream on a separate line
; each unique stream should be defined as stream = [url]
stream = http://127.0.0.1:8080/stream/video.mjpeg
;stream = http://127.0.0.1/example_second_stream.mjpeg
;stream = webcam
; topn is the number of possible plate character variations to report
topn = 10
; Determines whether images that contain plates should be stored to disk
store_plates = 0
store_plates_location = /var/lib/openalpr/plateimages/
; upload address is the destination to POST to
upload_data = 0
upload_address = http://localhost:9000/push/
Save the file, exit and reboot by typing:
shutdown -r now
whent he reatart is complete reopen tthe terminal and type:
alprd -f
and see if the daemon connects to the stream.
----------------------
note: there is additonal information out the mjpg-stream command line parms that is relevant at http://rpm.pbone.net/index.php3/stat/45/idpl/23775320/numer/1/nazwa/mjpg_streamer
when you are done, reboot before issuing the final command to run the streamer:
raspistill --nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0 &
note that the portion of the command where it says 'tl 100' is the time between stills in milliseconds.
This was generating dropped frames when I ran it, so I have modifed this to 'tl 5000' to generate a frame every 5 seconds
now make it all run automagically:
cd /etc
sudo nano rc.local
at the bottom of the file, BEFORE it says 'exit 0' insert the following lines:
mkdir /tmp/stream
raspistill --nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 2500 -t 9999999 -th 0:0:0 &
LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i "input_file.so -f /tmp/stream -n pic.jpg" -o "output_http.so -w /usr/local/www" &
^O to write the file, ^X to back out
shutdown -r now to reboot
again, test the streamer by opening a browser and going to:
http://localhost:8080/stream_simple.html
Installing the alprd daemon and getting the results
Documents and files: These are the references I found for the next section:
openalprd daemon: http://doc.openalpr.com/alprd.html#open-source-agent
openalprd daemon relies on beanstalkd: http://kr.github.io/beanstalkd/
programmatically accessing beanstalkd requires beanstalkc: https://github.com/earl/beanstalkc
Installing beanstalkd on a raspberry pi: http://raspberrypirobot.blogspot.com/2012/09/raspberry-configuration.html
Install beanstalkd (and all of the rest just to get a Python interface library) for inter-process queue management:
sudo apt-get install beanstalkd
Install PIP (all the rest is to get support for Python):
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
Install PyYAML:
sudo apt-get build-dep python-yaml
sudo pip install PyYAML
install beanstalkc:
sudo pip install beanstalkc
add a line to rc.local to start beanstalkd automatically on boot:
cd /etc
sudo nano rc.local
on the second last line, immediately before 'exit 0' add the following line:
beanstalkd &
^O to save, ^X to exit
@carflomi

This comment has been minimized.

Copy link

@carflomi carflomi commented Jan 24, 2017

Hello first at all Very interesting your information, thanks
And second my question
I follows all your indications but i have a problem in the line number 89 (alprd -f ) I see the next information.
INFO - Video stream connecting...
WARN - Stream http://127.0.0.1:8080/stream/video.mjpeg?openalprfiletype=file.mjpg failed to open.

Do you have any idea about what it's wrong?

Thanks

@AviFix

This comment has been minimized.

Copy link

@AviFix AviFix commented Oct 31, 2018

same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.