Leak Society
/
General Discussion
/
Technology and Devices
/
How to set up your RPi as live web camera feed (CCTV)





How to set up your RPi as live web camera feed (CCTV)
Thead Owner : Slash1644926389,
Category : Technology and Devices,
4 Comment,
136 Read
Viewers:
1 Guest(s)
03-08-2014, 02:37 PM
So you heard of these cool little computer's that are the size of a credit card, you then
went out and bought one but have no clue what to do with it? Well, this tutorial will take
you through one of the many possibilities that your RPi can be set up to have.
This tutorial will help you achieve :
- Setting up a web camera live feed to stream over your local network (port fowarding is
possible though look at port forwarding here).
You need :
-Raspberry Pi Model B (512Mb RAM)
-A usb compatible web camera (Compatible webcams with RPi here)
- (Optional) - USB Extension lead (So you can have the camera far away from the RPi)
Step 1 - (Setup the Camera) :
Place your camera in a suitable place in which you want the feed. You can take apart the
camera if you wish, you can have it in plain sight do whatever, I have mine looking out my
window of my house at my front door.
Step 2 - (Setup the RPi) :
In order for the RPi to boot up, you need to have a OS installed onto it, I personally use
Raspbian which is debian-based OS that is specially tailored towards the RPi and its
hardware. But to install the OS I recommend looking at this
Because once you have set the stream up you will not need a monitor, I recommend looking
into setting up SSH (Secure Shell) on your RPi, this is so you can remote control the RPi from another node.
Lastly, forcing your RPi to have a static IP address is suggested as it will be easy to find the webcam server even if there is a problem with the pi, causing a restart. went out and bought one but have no clue what to do with it? Well, this tutorial will take
you through one of the many possibilities that your RPi can be set up to have.
This tutorial will help you achieve :
- Setting up a web camera live feed to stream over your local network (port fowarding is
possible though look at port forwarding here).
You need :
-Raspberry Pi Model B (512Mb RAM)
-A usb compatible web camera (Compatible webcams with RPi here)
- (Optional) - USB Extension lead (So you can have the camera far away from the RPi)
Step 1 - (Setup the Camera) :
Place your camera in a suitable place in which you want the feed. You can take apart the
camera if you wish, you can have it in plain sight do whatever, I have mine looking out my
window of my house at my front door.
Step 2 - (Setup the RPi) :
In order for the RPi to boot up, you need to have a OS installed onto it, I personally use
Raspbian which is debian-based OS that is specially tailored towards the RPi and its
hardware. But to install the OS I recommend looking at this
Because once you have set the stream up you will not need a monitor, I recommend looking
into setting up SSH (Secure Shell) on your RPi, this is so you can remote control the RPi from another node.
To do this, first type in the RPi command prompt :
Code:
ifconfig
This will return some information about your router, If you have an ethernet connection to your Pi check the etho part, if you have a wireless adapter and therefore a wireless connection check out the wlano part.
Make a note somewhere about the following information :
inet addr - 192.168.1.5 (pi's IP Address)
Bcast - 192.168.1.255 (broadcast IP Range)
Mask - 255.255.255.0 (subnet mask)
Once you have done this, run this command in the command prompt :
Code:
route -n
and note the following information that is returned :
Gateway Address - 192.168.1.1
Now you have this information we have to do some edits, run the following command in the command prompt :
Code:
sudo nano /etc/network/interfaces
Code:
iface wlan0 inet dhcp (for wifi)
or
iface etho inet dhcp (for ethernet)
once you have found the information change the entry to (Using the information you got and noted down earlier from ifconfig):
Code:
iface wlan0 inet static (for wifi users)
iface etho inet static (for ethernet users)
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
Please reboot your pi now! - You have given it a static address!
Step 3 - (Setup the Motion Detection) :
Firstly you must update the rpi image to add the missing UVC support. To do this type :
Code:
sudo apt-get install rpi-update
sudo rpi-update
Code:
sudo apt-get update
sudo apt-get upgrade
Code:
sudo apt-get install motion
Code:
lsusb
Code:
Bus 001 Device 002: ID 046d:0821 CBR CW 835M Black
Now we have to configure the motion package!
Code:
sudo nan /etc/motion/motion.conf
This is a big configuration file, but dont get intimidated by it just follow exactly what I say to do. As it will define what port to run on , what actions will be done, where to stream it etc.
The following list of variables are the ones you want to find and configure :
daemon : make sure this is set to ON, so daemon starts when pi is loaded
webcam_localhost : set to OFF so the motion can be access from other computers
stream_port : the port for the video to stream to (def is 8081)
control_localhost : set to OFF to be able to config the variables through a web browser
control_port : the port that if you want to edit variables through the browser (def is 8080)
framerate : FPS Essentially, I recommend leaving it as it is - But if you put the rate to above 4 it will seriously harm your Pi's peformance.
post_capture : the amount of frames that should be captured after motion has been detected.
Once you have done this press CTRL + X to save and exit the editor!
You will now need to modify this file :
Code:
sudo nano /etc/default/motion
Code:
start_motion_daemon=yes
Once you have done this press CTRL + X to save and exit the editor!
Then start the service by typing :
Code:
sudo service motion start
Then wait for roughly a minute to allow the service to set up, once you have waited get a video stream player such as VLC and open a network or video stream using the IP address of your pi followed by the stream_port. For example of this tutorial :
Code:
192.168.1.5:8083
Enjoy your feed!
03-09-2014, 04:39 AM
Nice tutorial, how long did this take to write?
Forum Owner
Guest
Unregistered
4 Years of Service
03-09-2014, 05:42 AM
Nice tutorial man, very HQ. But that's a lot of work for something small.
03-09-2014, 09:09 AM
(03-09-2014, 04:39 AM)Malevolent Wrote: Nice tutorial, how long did this take to write?
Hour? Had to go through each step making sure it was the correct step
(03-09-2014, 05:42 AM)Meh Wrote: Nice tutorial man, very HQ. But that's a lot of work for something small.
It isnt that much compared to robotics on the RPi or Arduino :)
(03-09-2014, 05:57 AM)DeLiLa Wrote: DAMMIT I WAS GOING TO MAKE A TUTORIAL FOR THIS >:OO xD
I got there first! haha!