Wednesday, January 21, 2015

Make your Raspberry PI a Web Cam Server

The Raspberry PI is perfectly equipped to turn your USB based web cam into a fully functional IP web cam that you can have lots of fun with, from there you could use tools such as Python to make your project more unique, im having a go at counting passing traffic.
If your wanting to something a bit more simple you could just have a web cam that can be access from anywhere with an internet connection, which is what you will end up with at the end of this guide.
Your shopping list…
  • Raspberry Pi with an OS installed – Amazon US
  • USB Powered Hub – Amazon US
    • Important; This one worked for me, however it’s not worked for others, you will find this is the case with a lot of the powered USB hubs, research before buying.
    • We need a hub because the camera’s draw more power than the Raspberry Pi can actually provide, you see the same with some keyboards and USB dongles.
  • Web Cam
    • PS3 Eye Toy –  Amazon US
    • Microsoft HD –  Amazon US
You could also look at an external power back and WiFi if you want to make it mobile, a few people have put these in a garden or somewhere without a static power/network source.
1. Get the software ready
Ok so I am going to assume that you have a working PI on some kind of LAN with internet access, the next step as always is to update your PI ensuring you have the latest software and drivers installed.
?
1
2
sudo apt-get update
sudo apt-get upgrade
Now we need to install the software, we are going to be using a great little application called Motion, this will do a few things for us including accessing the USB cam, getting the images, and streaming them via a built in web server. As the name suggests it will also track and trigger events on motion been detected in the video frames (more on that later).
?
1
sudo apt-get install motion
2. Plug in your web cam
So now the software is on there it’s time to plug in the web cam and ensure that everything is working, ensuring that you plug it into the powered hub, and then into the PI. Otherwise the webcam will not get enough power to turn on.
When plugged in type the “lsusb” command, you should see a line there with your web cam manufacture, that proves that you have the basic connectivity working.
?
1
2
3
4
lsusb
....
Bus 001 Device 002: ID 04ea:1142 Microsoft Corp.
....
3. Configure the software
?
1
sudo nano /etc/motion/motion.conf
In here there are a few basic changes that you need to perform:
  • Daemon = OFF to ON
  • webcam_localhost = ON to OFF
You can change other settings but it’s recommend you don’t take more than 2 frames, and you been the default frame pixel size, for stability.
4. Start the software
To ensure that the motion service will actually start as a daemon we need to change another configuration setting, so enter the following:
sudo nano /etc/default/motion
Then change the value “start_motion_daemon=no” to “yes”
Finally you can start the motion service to stream the web cam images
?
1
sudo service motion start

http://192.168.0.100:8081
Then after about 30 seconds browse to the new web interface, which should be at the below URL (where 192.168.0.100 is your Raspberry PI’s IP address)
5. Final Tweeks
Web Port
You could change the web interface port to 80 (from the default 8081), so that you can just browse to the IP address without having to put :8081 at the end, it’s really simple to do, just:
?
1
sudo nano /etc/motion/motion.conf
And then change “webcam_port 8081″ to “webcam_port 80″, save the file, and restart the motion service.
?
1
sudo service motion restart
Port Forwarding
Final suggestion is enable port forwarding on your home broadband router to the Raspberry PI on port 80, that will mean you can access the web cam from anywhere in the world. There are too many routers in the word to explain how to do it here, but I am sure you will find some help on Google, if not please just leave a comment.
Warning; If you give it internet access via port forwarding this does take up quite a bit of bandwidth, and anyone can see your webcam feed, so only show what you want people to see.

5 comments:

  1. i am a successful business owner and father. I got one of these already programmed blank ATM cards that allows me withdraw a maximum of $5,000 daily for 30 days. I am so happy about these cards because I received mine last week and have already used it to get $20,000. Skylink technology is giving out these cards to support people in any kind of financial problem. I must be sincere to you, when i first saw the advert, I believed it to be illegal and a hoax but when I contacted this team, they confirmed to me that although it is illegal, nobody gets caught while using these cards because they have been programmed to disable every communication once inserted into any Automated Teller Machine(ATM). If interested get through to them on mail: skylinktechnes@yahoo.com  or  whatsapp/telegram: +1(213)785-1553  

    ReplyDelete