So now I’ve bought the Camera Module for the Raspberry Pi. I got mine from Amazon, mainly as I was putting in a big order and was drunk enough to tag it on to the end.
Getting the damn thing set up and streaming video through a web page was a Pain In The Arse (which I know about)!
The only resource I could find that worked was Miguel Grinberg’s guide, but I still had problems with that. I suggest that you read his site, as it contains a lot more information. My version, below, is a quick run through, more for me to refer back to than anything else.
1. Build and Install the software
Run the following as root:
$ apt-get install libjpeg8-dev imagemagick libv4l-dev
$ ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
$ wget http://sourceforge.net/code-snapshots/svn/m/mj/mjpg-streamer/code/mjpg-streamer-code-182.zip
$ unzip mjpg-streamer-code-182.zip
$ cd mjpg-streamer-code-182/mjpg-streamer $ make mjpg_streamer input_file.so output_http.so
$ sudo cp mjpg_streamer /usr/local/bin $ sudo cp output_http.so input_file.so /usr/local/lib/ $ sudo cp -R www /usr/local/www
2. Start the Camera and Streamer
Starting “raspistill” as suggested in Miguel’s guide dumped a lot of text to my xterm, making things really annoying, so I installed “screen” and ran the Camera software and the streamer in a different “screen”, which would also keep running after I logged off the machine (follow the oncreen prompts when you see them):
$ apt-get install screen
$ mkdir /tmp/stream
raspistill --nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -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" &
Dropping out of “screen” ( CRTL-A CTRL-D ) and back to a command prompt, and its all done.
3. Viewing the Stream
Fire up your favourite Browser (which I hope is Firefox) and access the site generate by th Pi. As the eventual goal of this whole thing a Wifi controlled toy Dalek drone, the hostname is “dalek”. Thus, on my network the address is:
You’ll have to substitute dalek for either the name of the machine on your network, or the IP address, eg:
You should be getting a web page with instructions on how it all works.
To grab a single from the camera:
To grab streaming video:
There other things you can play with, but those two are the only ones relevant to my little project.
Finally, an example of a still picture from the camera:
(Once again, full credit to Miguel Grinberg and his excellent guide.)