Skip to content

Instructions for setting up a Raspberry Pi to act as a webcam

Notifications You must be signed in to change notification settings

ChalmersRobotics/rpi-webcam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Raspberry Pi Webcam

Goal

The goal of theese instructions is to provide a way for a Raspberry Pi (RPi) to act as a 'webcam' at CRF. The webcam images are then regularly published to the Image API in crf-dashboard using a Node-RED flow on our local server. This replaces the code in the crf-webcam repository, but does not include the same amount of features. Most importantly it lacks the annonymize feature which used to blur faces (but did not work very well) and the 'detect movement' feature.

This repository contains instructions for installing mjpeg_streamer on a RPi running Raspbian for making it act as a simple network attached camera, and how to keep the RPi updated automaticaly.

Note: Theese instructions have been testen on a Raspberry Pi 2 Model B running Raspbian Stretch Lite. There is no guarantee that the method described here works without requiring any modifications on your system.

Installation

First, make sure that your Pi is updated

sudo apt-get update
sudo apt-get upgrade

and install the required dependencies

sudo apt-get install cmake libjpeg8-dev 

Clone jacksonliam's fork of mjpg-streamer from GitHub:

git clone https://github.com/jacksonliam/mjpg-streamer.git

and then enter the code directory:

cd mjpg-streamer/mjpg-streamer-experimental

Next, build and install mjpg-streamer and its dependencies using

make
sudo make install

The compilation should finnish without any errors.

You can now test your setup by running the following command (assuming that your camera is plugged in and working using raspistill)

mjpg_streamer -o "output_http.so" -i "input_raspicam.so --width 1640 --height 1232 -fps 15 -quality 10"

Feel free to configure the options to your liking according to the documentation.

The stream should now be accessible by visiting http://<IP>:8080/?action=stream. If you want snapshot jpeg images, visit http://<IP>:8080/?action=snapshot instead. Press Ctrl-C to stop the stream when you are done.

If you want the stream to start at boot there multiple options. One way is to edit the file /etc/rc.local and add the above command, followed by an ampersand (&) right before the exit 0 line. The line should look like:

mjpg_streamer -o "output_http.so" -i "input_raspicam.so --width 1640 --height 1232 -fps 15 -quality 10" &

Another way is to use crontab and use the @reboot command. Edit the root crontab file using sudo crontab -e and add the line

@reboot /usr/local/bin/mjpg_streamer -o "output_http.so" -i "input_raspicam.so --width 1640 --height 1232 -fps 15 -quality 10" &

Notice that the full path to the mjpg_streamer executable has to be specified and can be found by for example using the command type mjpg_streamer.

Now reboot to make sure it works:

sudo reboot

Automatic updates

When mounting several Raspberry Pi's (such as at CRF), one does not want to have to manually keep them updated. Here is where crontab comes into play. Using the following cron job, the RPi will automatically check for, and update, packages and also perform a system reboot.

Simply edit your crontab file as before (sudo crontab -e) and add the following line to it

0 2 * * 0 sudo apt -y update && sudo apt -y dist-upgrade && sleep 1800 && sudo /sbin/reboot

Theese lines simply make the RPi update every sunday at 02:00 starting with apt update and then following with an apt dist-upgrade , a delay of 30 minutes and lastly a reboot. The -y flag make sure the commands run without any user interaction. See the crontab quick refence for a more in-depth explanation about the definition of cron jobs.

Additional Links

For more information and/or troubleshooting, here are some links that may help.

About

Instructions for setting up a Raspberry Pi to act as a webcam

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published