ALPR daemon setup for Raspberry Pi camera

1,921 views
Skip to first unread message

Timis Daniel

unread,
Nov 4, 2015, 10:08:18 AM11/4/15
to OpenALPR
So i'm new to this.
Trying to make the daemon run with a stream from the Raspberry Pi camera module but i'm haveing  a hard time understanding how to link the mjpg stream from the camera to the ALPR daemon.

Can anyone give me a hint how to set up the mjpg stream and the alprd.config for this?

Matt

unread,
Nov 10, 2015, 3:49:57 AM11/10/15
to OpenALPR
You will add a "stream = [url]" entry to the alprd.conf.  Then when you restart the daemon it will show you some information in the logs about whether or not it was able to connect.

You can test that stream URL in VLC or Firefox.  The correct stream URL will display a video.  Sometimes you need to add a password to the url (e.g., http://[user]:[pass]@[camera_ip]/mjpegstreampath

Timis Daniel

unread,
Nov 13, 2015, 1:53:54 PM11/13/15
to OpenALPR
Well after looking into it i was doing it the right way. Problem was that i was missing gstreamer and OpenCV didn not compile the video module that is supposed to handle streaming.
I (think) i managed to correctly install gstreamer and compile OpenCV with th required modules. But now i', having a problem building OPENAlpr.
I am following this guide: https://barclaysapps.wordpress.com/2014/07/06/openalpr-install-for-rpi-and-udoo-and-tre-and-yun/ for the installation of OpenAlpr but i can't get passed the CMakeLists.txt file part. I tryed to do as in the guide i doesn't work.

my OpenCV directory is in a different place. So I changed the Hints in teh CMakeLists.txt with the path of the OpenCV build on my system and not running cmake ./ says :
/home/pi/opencv/build/OpenCVConfig.cmake but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
-- Configuring incomplete, errors occurred!

Matt

unread,
Nov 14, 2015, 3:30:47 PM11/14/15
to OpenALPR
If you install OpenCV on your system, it should find it.  I would install it into /usr/ instead of /usr/local.  You can specify that when you run cmake.  For example:
cmake [arguments] -DCMAKE_INSTALL_PREFIX:PATH=/usr ..

The build it:
make

Then install it:
sudo make install

Alternatively, you don't have to install it, you would then modify the OpenALPR config to point to the opencv dir. 

Timis Daniel

unread,
Nov 16, 2015, 7:48:31 AM11/16/15
to OpenALPR
Still won't build. even with the additional CMAKE arguments. I still get the same error:

Timis Daniel

unread,
Nov 16, 2015, 8:04:24 AM11/16/15
to OpenALPR
I know I'm doing(or did) something wrong, but I don't know what it is or how to figure out what the bad step was. I had already managed to compile both OpenCV, OpenALPR a couple of times, even on different OS with different compiler.

COuld it be that maybe my OpenCV installation is broken? I used Virtual Eviroment as the guide i pointed to indicated. I think that is most relevant different thing I tried for this build. Also is there any way to check the if the OpenCV installation has gone through well. I haven't build the examples, and there is no make checkinstall call for OpenCV(at least not in the form of make checkinstall).

Timis Daniel

unread,
Nov 16, 2015, 9:42:43 AM11/16/15
to OpenALPR
So far I tryed to run these commands:
cmake ./ -DCMAKE__INSTALL_PREFIX:PATH=/home/pi/opencv/build/bin
cmake ./ -DCMAKE__INSTALL_PREFIX:PATH=/home/pi/opencv/build

I get this error msg:
home/pi/opencv/build/bin -- Found Tesseract -- OpenCV ARCH: -- OpenCV RUNTIME: -- OpenCV STATIC: ON CMake Warning at /home/pi/opencv/cmake/OpenCVConfig.cmake:166 (message): Found OpenCV Windows Pack but it has no binaries compatible with your configuration. You should manually point CMake variable OpenCV_DIR to your build of OpenCV library. Call Stack (most recent call first): CMakeLists.txt:83 (FIND_PACKAGE) CMake Error at CMakeLists.txt:83 (FIND_PACKAGE): Found package configuration file: /home/pi/opencv/cmake/OpenCVConfig.cmake but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND. -- Configuring incomplete, errors occurred!

Hope this helps you help me :). If you need any other info about what i have done , please tell me.

Timis Daniel

unread,
Nov 18, 2015, 12:09:33 PM11/18/15
to OpenALPR
well back to ground zero
openalpr installed and working
can't manage to get the deamon to read the stream

i tried with each of these stream url:
;stream = webcam
and created the stream running mjpg-streamer with this command ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"

which displays this:

MJPG Streamer Version: svn rev: 
 DBG(/home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c, input_init(), 125): argv[0]=raspicam input plugin
 i: fps.............: 5
 i: resolution........: 640 x 480
 i: camera parameters..............:

Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 400, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
 o: www-folder-path...: ./www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled
 i: Starting Camera
 DBG(/home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c, worker_thread(), 572): Host init, starting mmal stuff
 DBG(/home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c, worker_thread(), 748): Camera enabled, creating encoder
Encoder Buffer Size 81920
 DBG(/home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c, worker_thread(), 831): Encoder enabled, creating pool and connecting ports
 DBG(/home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c, worker_thread(), 955): Starting video output

I can see th stream in my browser at :

trying to run alprd with ./alprd --config path to alprd.conf containing the above mentioned streams -f

and it says:

INFO - Running OpenALPR daemon in the foreground.
FATAL - No video streams defined in the configuration.


--
You received this message because you are subscribed to a topic in the Google Groups "OpenALPR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openalpr/3nsRXRnG6mU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openalpr+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Bissell

unread,
Nov 18, 2015, 5:40:12 PM11/18/15
to OpenALPR
Hi,

Are you using the alprd.conf file located in /etc/openalpr/ ?

If not try using that file with your streams added and see if you get the same issue.

Matt

unread,
Nov 20, 2015, 1:58:08 AM11/20/15
to OpenALPR
Are you running a program that relays your webcam to an MJPEG stream over the loopback?

If so, it may be simpler to just have OpenALPR connect to the webcam directly.  You can use "webcam" for the stream, or /dev/video[number] to point it to the webcam
Message has been deleted

Timis Daniel

unread,
Nov 25, 2015, 9:26:39 AM11/25/15
to OpenALPR
Hy guys.

Update: if I try to use a stream created with the mjpgstreamer now it connects to the stream, but OpenCV says gstreamer is missing a plugin. I tried browsing around and I think I have all gstreamer1.0 plugins installed:
OpenCV Error: Unspecified error (GStreamer: your gstreamer installation is missing a required plugin
) in handlemessage, file /home/pi/openalpr/src/build/opencv/modules/videoio/src/cap_gstreamer.cpp, line 1621
WARN - VideoBuffer OpenCV exception: /home/pi/openalpr/src/build/opencv/modules/videoio/src/cap_gstreamer.cpp:1621: error: (-2) GStreamer: your gstreamer installation is missing a required plugin
 in function handlemessage

Using the webcam
I get this error message now:
INFO - Video stream connecting...
INFO - Video stream connected
GStreamer Plugin: Embedded video playback halted; module v4l2src3 reported: Cannot identify device '/dev/video0'.
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in icvStartPipeline, file /home/pi/openalpr/src/build/opencv/modules/videoio/src/cap_gstreamer.cpp, line 380
WARN - VideoBuffer OpenCV exception: /home/pi/openalpr/src/build/opencv/modules/videoio/src/cap_gstreamer.cpp:380: error: (-2) GStreamer: unable to start pipeline
 in function icvStartPipeline

I must point out that the camera red LED doesn't turn on.
The camera works and red Led turns on when i take a picture or record a video.

Matt

unread,
Dec 7, 2015, 4:17:47 AM12/7/15
to OpenALPR
Probably gstreamer doesn't have the necessary plugins installed on the system.  If you're running Ubuntu, you can get it with apt-get.  For example (if you compiled OpenCV to use GStreamer 0.10):

sudo apt-get install libgstreamer-plugins-base1.0-0  libgstreamer-plugins-good1.0-0
Message has been deleted

Timis Daniel

unread,
Dec 7, 2015, 1:13:48 PM12/7/15
to OpenALPR
So the problem was I was missing a driver the uv4l which I got from here

It works now, it identifies the number plates i printed on a sheet of paper and "wave" in front of the camera. It works very well, quite precise(with a well mounted camera and less shaking numberplates passing in front of it it should work wonders) and very very fast.

My problem now is that it says it can't connect to Beanstalkd:
WARN - Error connecting to Beanstalkd. Results has not been saved.

Matt

unread,
Dec 8, 2015, 2:15:52 AM12/8/15
to OpenALPR
Once you install beanstalkd (sudo apt-get install beanstalkd) it should run as a daemon in the background on port 11300.  Is the beanstalkd service running?  Is it listening on that port?

Timis Daniel

unread,
Dec 8, 2015, 8:15:04 AM12/8/15
to OpenALPR
Yes beanstalkd is installed and the service is running:

sudo service beanstalkd status
● beanstalkd.service - Simple, fast work queue
   Loaded: loaded (/lib/systemd/system/beanstalkd.service; enabled)
   Active: active (running) since Tue 2015-12-08 08:10:45 UTC; 2min 28s ago
     Docs: man:beanstalkd(1)
 Main PID: 498 (beanstalkd)
   CGroup: /system.slice/beanstalkd.service
           └─498 /usr/bin/beanstalkd -l 127.0.0.1 -p 11300

Dec 08 08:10:45 raspberrypi systemd[1]: Started Simple, fast work queue.

Timis Daniel

unread,
Dec 8, 2015, 10:09:34 AM12/8/15
to OpenALPR
So anyway it started working after my last reboot.
Strange but fine with me.
Trying to get the data out of the beanstalkd queue. I have Beanstalkc and PyYAML installed and I'm running this python script
#!/usr/bin/python
import beanstalkc
beanstalk = beanstalkc.Connection(host='localhost', port=11300)
while True:
        job = beanstalk.reserve()
        print 'Got data : %s' % job.body
        job.delete()

Nothing is printed. 
Disclaimer : I'm a noob at Pyton :)

So i'm clearly missing something, I will try and look at a couple of guides, examples and tutorials about python and beanstalkd/c online see if I can figure it out by myself. Hints and tips and tricks are very welcome anyway.

Best regards,
Daniel

Timis Daniel

unread,
Dec 8, 2015, 10:30:25 AM12/8/15
to OpenALPR
This is what I get after stopping the script:
CTraceback (most recent call last):
  File "script.py", line 5, in <module>
    job = beanstalk.reserve()
  File "/usr/local/lib/python2.7/dist-packages/beanstalkc.py", line 149, in reserve
    ['DEADLINE_SOON', 'TIMED_OUT'])
  File "/usr/local/lib/python2.7/dist-packages/beanstalkc.py", line 113, in _interact_job
    jid, size = self._interact(command, expected_ok, expected_err)
  File "/usr/local/lib/python2.7/dist-packages/beanstalkc.py", line 87, in _interact
    status, results = self._read_response()
  File "/usr/local/lib/python2.7/dist-packages/beanstalkc.py", line 96, in _read_response
    line = SocketError.wrap(self._socket_file.readline)
  File "/usr/local/lib/python2.7/dist-packages/beanstalkc.py", line 41, in wrap
    return wrapped_function(*args, **kwargs)
  File "/usr/lib/python2.7/socket.py", line 447, in readline
    data = self._sock.recv(self._rbufsize)
KeyboardInterrupt

Timis Daniel

unread,
Dec 8, 2015, 11:22:38 AM12/8/15
to OpenALPR
Well i found what I was looking for. everything works fine.

Matt

unread,
Dec 8, 2015, 1:15:03 PM12/8/15
to OpenALPR

Awesome, Timis.  Do you mind posting the resolution?  These threads are super helpful when other folks search for similar error messages -- it's always nice to hear what you did to fix it.

The Python exception on exit seems normal -- that's just a "CTRL+C" interrupt in Python being unhandled.   Your Python code also looks correct to me as well.

Timis Daniel

unread,
Dec 8, 2015, 1:51:33 PM12/8/15
to OpenALPR
So the problem was my script as I found out from examining another discussion on the topic linked herehttps://groups.google.com/forum/#!topic/openalpr/hmZ8A--8xOE

I would connect to the Beanstalkc but i didn't specify to watch the "alprd" queue. 

After looking at the above mentioned post I added some features to the script such as emptying the beanstalk and check if the identified license plate matched one from a text file.

Strange thing is I did a reboot and not it unable to connect to the beanstalk again.
I will investigate further and once i'm done I will post more details. Will also post my script after testing it a bit, arranging the code a bit better and adding some comments.

Timis Daniel

unread,
Dec 8, 2015, 2:06:06 PM12/8/15
to OpenALPR
Well it may seem that unless I plug the Raspberry Pi to the LAN it won't be able to use the Beanstalk queue.
Do you happen to know if there is any workaround for this?

Matt

unread,
Dec 9, 2015, 12:52:35 AM12/9/15
to OpenALPR
You could try changing the binding interface on beanstalkd.  It seems strange that the service wouldn't be able to bind to localhost.  What is the output of this command:
netstat -lnp | grep beanstalkd

If you edit /etc/init.d/beanstalkd:

BEANSTALKD_LISTEN_ADDR="127.0.0.1"

You could try changing that to "0.0.0.0" -- that may have an effect after you restart beanstalkd (/etc/init.d/beanstalkd restart)

Timis Daniel

unread,
Dec 9, 2015, 7:53:16 AM12/9/15
to OpenALPR
This fixed the LAN-Beanstalkd issue. Again thank you very much for the support.

Timis Daniel

unread,
Dec 15, 2015, 10:38:54 AM12/15/15
to OpenALPR
So it seems the fix for the LAN-Beanstalk Issue is only half solved. 
Every time I restart the Pi the daemon give an error when writing to the Beanstalk queue until I plug a LAN cable.
I can after that remove the cable and the and the daemon will continue to work, until the Pi reboots. Then it will require that I insert the LAN cable(even if for a short period of time, a couple of seconds maybe) again.
Any Ideas on how to work around this?

Reply all
Reply to author
Forward
0 new messages