CodePug.com

Home | Games | Media | Programming | Raspberry Pi | Misc Content

Raspberry Pi Image Recognition Initial Setup

The Raspberry Pi system provides a low power solution with enough CPU to perform realtime image recognition capabilities. For this I used a creative camera with UVC support so that I didn’t have to worry about compiling any special drivers into Raspbian.
On the software side, some starting steps to take may include installing a video capture software such as mjpg_streamer. First, grab some of the dependent utility and image processing libraries.

 sudo apt-get update
 sudo apt-get install libjpeg8-dev imagemagick
 sudo apt-get install subversion

You will also need to download the source and compile it for mjpg_streamer. cd ~ mkdir tmp cd tmp svn co https://svn.code.sf.net/p/mjpg-streamer/code cd code/mjpg-streamer make sudo make install After mjpg_streamer is built, then you can run it using a command similar to the following: ./mjpg_streamer -i “./input_uvc.so -n -f 15 -r 240x160” -o “./output_http.so -n -w ./www” The above command assumes that you have changed to the directory containing mjpg_streamer and the relevant *.so files.

The resolution can be changed from 240x160 to higher values depending on what your camera supports. I found that the lower resolution images were much more responsive in terms of any analysis that I needed to do on video. These numbers may need to vary depending on the work load placed on your Raspberry Pi and network interface bandwidth.

To automatically run mjpg_streamer on system startup, you can type ‘sudo nano /etc/rc.local’ and add something similar to: /usr/local/bin/mjpg_streamer -i “/usr/local/lib/input_uvc.so -n -f 15 -r 240x160” -o “/usr/local/lib/output_http.so -n -w /usr/local/www” &

One can then use the default or create a custom page to display the video. I used the following which I placed at /usr/local/www/index.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Live Feed

</code>

One can then use a computer vision analysis package such as OpenCV from another computer and process images streamed from the Raspberry Pi by connecting to the Raspberry Pi’s assigned IP address.