Basic Video Surveillance with the Raspberry Pi
<div>
<div>
<div>
<div>
<div><span><div><p style="text-align: justify;">Sometimes, you would like to monitor your home from another angle that what the Raspberry Pi camera can achieve. In order to do that, you will need to use an external USB camera.</p><p style="text-align: justify;">In this project we are going to see how to connect an external USB camera to your Raspberry Pi, and make a simple video surveillance system from it, allowing you to see in live what is seen by the camera.</p><p style="text-align: justify;">To do that, we will first connect a USB camera to your Pi, and then test if it works correctly. After that, we will configure the Raspberry Pi so it streams the video continuously on a web page.</p><p style="text-align: justify;"></p><h2>Hardware & Software Requirements</h2><p style="text-align: justify;">Apart from the Raspberry Pi itself, the most important component of this chapter will be the USB camera. You need a camera that is compatible with the UVC standard, which is the case for most of the cameras you will find today. I used a Logitech C720 HD camera for this project.</p><p style="text-align: justify;">This is the list of the components you will need for this project:</p><ul style="text-align: justify;"><li><a href="http://a-fwd.com/asin-com=B00T2U7R7I&com=openhomeautomation-20&ca=openhomeauto-20&uk=openhomeaut09-21&de=openhomeauto-21&fr=leblosed-21&it=openhomeaut08-21&es=openhomeau028-21&sc=w" target="_blank">Raspberry Pi</a></li><li><a href="http://a-fwd.com/asin-com=B004FHO5Y6&com=openhomeautomation-20&ca=openhomeauto-20&uk=openhomeaut09-21&de=openhomeauto-21&fr=leblosed-21&it=openhomeaut08-21&es=openhomeau028-21&sc=w" target="_blank">Logitech C270 USB camera</a></li><li><a href="http://a-fwd.com/asin-com=B003MTTJOY&com=openhomeautomation-20&ca=openhomeauto-20&uk=openhomeaut09-21&de=openhomeauto-21&fr=leblosed-21&it=openhomeaut08-21&es=openhomeau028-21&sc=w" target="_blank">USB WiFi dongle (optional)</a></li></ul><h2>Hardware Configuration</h2><p style="text-align: justify;">The hardware configuration is really simple: you just need to plug the camera in your Pi, using one of the USB port on the Raspberry Pi.</p><p style="text-align: justify;">This is a close-up of the final result:</p><p style="text-align: justify;"><img src="/cdn/files/62ce81aed27eac118b9655da.png"><br>
</p><h2>Testing the Camera</h2><p style="text-align: justify;">We are now going to test the camera. Again this is really easy to do. Just type this in a terminal:</p><p style="text-align: justify;"><em>sudo apt-get install fswebcam</em></p><p style="text-align: justify;">Then, take a picture with:</p><p style="text-align: justify;"><em>fswebcam -r 1280×720 image.jpg</em></p><p style="text-align: justify;">The camera LED should turn on, which means it is active and currently taking a picture. Then, simply check the image that was created by the command.</p><h2>Local Video Streaming</h2><p style="text-align: justify;">We will now stream video locally using the mjpg-streamer module. This module is really great for video streaming, as it will create a nice web page from which you can access the video stream.</p><p style="text-align: justify;">However, the module is not available in the official Raspberry Pi Linux repository. But luckily for us, a developer made a version available for the Raspberry Pi, and we are going to install it now. You can find all the details at:</p><p style="text-align: justify;"><a href="https://github.com/jacksonliam/mjpg-streamer">https://github.com/jacksonliam/mjpg-streamer</a></p><p style="text-align: justify;">First type the following command in a terminal from your Pi:</p><p style="text-align: justify;"><em>git clone https://github.com/jacksonliam/mjpg-streamer</em></p><p style="text-align: justify;">Then type this command to install required modules:</p><p style="text-align: justify;"><em>sudo apt-get install cmake libjpeg62-dev</em></p><p style="text-align: justify;">After that, type this command to build the mjpg-streamer package:</p><p style="text-align: justify;"><em>sudo make clean all</em></p><p style="text-align: justify;">And then type this command:</p><p style="text-align: justify;"><em>export LD_LIBRARY_PATH=.</em></p><p style="text-align: justify;">And finally type this command to start the streaming:</p><p style="text-align: justify;"><em>./mjpg_streamer -i “./input_uvc.so” -o “./output_http.so -w ./www”</em></p><p style="text-align: justify;">You will see that a lot of text will be printed inside the terminal, which means the streaming is active. Then, go to this URL from a computer:</p><p style="text-align: justify;"><em>http://rpi_ip_address:8080</em></p><p style="text-align: justify;">This is the web page you should get:</p><p style="text-align: justify;"><img src="/cdn/files/62ce81b9d27eac118b9655f9.png"><br>
</p><p style="text-align: justify;">Simply go on ‘Stream’ in the menu, and you should see live streaming from the USB camera connected to your Pi!</p><p style="text-align: justify;">If you just want to see the stream, go to:</p><p style="text-align: justify;"><em>http://rpi_ip_address:8080/javascript_simple.html</em></p><p style="text-align: justify;"><img src="/cdn/files/62ce81c4d27eac118b96561e.png"><br>
</p><h2>How to Go Further</h2><p style="text-align: justify;">In this project, we built a basic surveillance camera using the Raspberry Pi camera module and some open-source software.</p><p style="text-align: justify;">You can now of course add more Raspberry Pi modules in the game, to make a whole surveillance system! From the mjpg-streamer module it is easy to get a piece of code that can be embedded in another web page.</p><p style="text-align: justify;">From that, it is easy to build a page where you have the pictures from all your camera modules, and monitor them from a single interface!</p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div><h3></h3><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p></div></div></div></div></div></div></div></div></div></div></span></div></div></div></div></div>