{"id":80,"date":"2013-08-01T14:29:03","date_gmt":"2013-08-01T14:29:03","guid":{"rendered":"http:\/\/blog.soton.ac.uk\/pi\/?page_id=80"},"modified":"2013-08-23T15:12:39","modified_gmt":"2013-08-23T15:12:39","slug":"trust-webcam","status":"publish","type":"page","link":"https:\/\/blog.soton.ac.uk\/pi\/trust-webcam\/","title":{"rendered":"Trust Webcam"},"content":{"rendered":"<div>\n<h2><a title=\"Permanent Link to How To: Raspberry PI Web Cam Server\" href=\"http:\/\/pingbin.com\/2012\/12\/raspberry-pi-web-cam-server-motion\/\" rel=\"bookmark\">1) How To: Raspberry PI Web Cam Server<\/a><\/h2>\n<\/div>\n<p>The Raspberry PI is perfectly\u00a0equipped\u00a0to 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. As a simple configuration, we will configure a web cam that can be accessed from anywhere with an internet connection.<\/p>\n<h5>1. Get the software ready<\/h5>\n<p>Type in the following in the command line to make sure everything is up-to-date on the Raspberry Pi.<\/p>\n<div>\n<div id=\"highlighter_586805\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<div>2<\/div>\n<\/td>\n<td>\n<div>\n<div><code>sudo<\/code> <code>apt-get update<\/code><\/div>\n<div><code>sudo<\/code> <code>apt-get upgrade<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Now we need to install the software, we are going to be using an application called Motion, this will do a few things\u00a0 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).<\/p>\n<div>\n<div id=\"highlighter_85373\">\n<div><\/div>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<\/td>\n<td>\n<div>\n<div><code>sudo<\/code> <code>apt-get <\/code><code>install<\/code> <code>motion<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h5>2. Plug in your web cam<\/h5>\n<p>So now the software is on there it\u2019s 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.<\/p>\n<p>When plugged in type the \u201clsusb\u201d command, you should see a line there with your web cam manufacturer, that proves that you have the basic connectivity working.<\/p>\n<div>\n<div id=\"highlighter_423240\">\n<div><\/div>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<div>2<\/div>\n<div>3<\/div>\n<div>4<\/div>\n<\/td>\n<td>\n<div>\n<div><code>lsusb<\/code><\/div>\n<div><code>....<\/code><\/div>\n<div><code>Bus 001 Device 002: ID 04ea:1142 Microsoft Corp.<\/code><\/div>\n<div><code>....<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h5>3. Configure the software<\/h5>\n<div>\n<div id=\"highlighter_551891\">\n<div><\/div>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<\/td>\n<td>\n<div>\n<div><code>sudo<\/code> <code>nano <\/code><code>\/etc\/motion\/motion<\/code><code>.conf<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>In here there are a few basic changes that you need to perform:<\/p>\n<ul>\n<li>Daemon = change from OFF to ON<\/li>\n<li>webcam_localhost = change from ON to OFF<\/li>\n<\/ul>\n<h5>4. Start the software<\/h5>\n<p>To ensure that the motion service will actually start as a daemon we need to change another configuration setting, so enter the following:<\/p>\n<pre><strong>sudo nano \/etc\/default\/motion<\/strong><\/pre>\n<p>Then change the value of \u201cstart_motion_daemon=no\u201d to \u201cyes\u201d<\/p>\n<p>Finally you can start the motion service to stream the web cam images<\/p>\n<div>\n<div id=\"highlighter_838070\">\n<div><\/div>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<\/td>\n<td>\n<div>\n<div><code>sudo<\/code> <code>service motion start<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Then after about 30 seconds browse to the new web interface, which should be at the below URL (where <strong>152.78.64.206<\/strong> is your Raspberry PI\u2019s IP address).<\/p>\n<p>http:\/\/<strong>152.78.64.206<\/strong><\/p>\n<p>To find your Pi`s IP address type <strong>ifconfig <\/strong>in a command terminal. Under <strong>eth0 <\/strong>you should see an address similar to: <strong>inet addr:152.78.64.206<\/strong> which is the Pi`s IP address.<\/p>\n<h5>5. Final Tweeks<\/h5>\n<p><strong>Web Port<\/strong><\/p>\n<p>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. To do this, type<\/p>\n<div>\n<div id=\"highlighter_557319\">\n<div><\/div>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<\/td>\n<td>\n<div>\n<div><code>sudo<\/code> <code>nano <\/code><code>\/etc\/motion\/motion<\/code><code>.conf<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>And then change \u201cwebcam_port 8081\u2033 to \u201cwebcam_port 80\u2033, save the file, and restart the motion service.<\/p>\n<div>\n<div id=\"highlighter_158620\">\n<div><\/div>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<\/td>\n<td>\n<div>\n<div><code>sudo<\/code> <code>service motion restart<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<blockquote class=\"wp-embedded-content\" data-secret=\"I7ABUKpzWE\"><p><a href=\"https:\/\/pingbin.com\/2012\/12\/raspberry-pi-web-cam-server-motion\/\">How To: Raspberry PI Web Cam Server<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;How To: Raspberry PI Web Cam Server&#8221; &#8212; PingBin\" src=\"https:\/\/pingbin.com\/2012\/12\/raspberry-pi-web-cam-server-motion\/embed\/#?secret=KWnWFhcvpt#?secret=I7ABUKpzWE\" data-secret=\"I7ABUKpzWE\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2) Scanning QR Codes<\/strong><\/p>\n<p>You can use your Webcam to scan QR Codes with the help of a tool such as <strong>zbar tools.<\/strong> To use zbar tools, all you need to do is install it by typing:<\/p>\n<p><strong>sudo apt-get zbar-tools<\/strong><\/p>\n<p>Now verify how your webcam shows up by typing:<\/p>\n<p><strong>ls \/dev\/video*<\/strong>. You should get something like: <strong>\/dev\/video0. <\/strong>Now type the following command, replacing 0 with the number your video webcam showed at, and the zbarcam tool will show up<br \/>\n<strong>zbarcam \/dev\/video0\u00a0<\/strong><\/p>\n<p>Provided that the camera is in focus, it should at this point be able to scan qr codes quite easily. Try to point it out at different qr codes and you should get the output in the terminal. You can check this on codes generated on the screen or on printed qr codes.<\/p>\n<p>To generate a qr code, you can use a free online tool. http:\/\/goqr.me\/ is a good one to start with. You can select what type of output it gives: a message, a website, or any other option, and then hit &#8220;Download&#8221; to get the .png file with the qr code in your desired location. Once you have this, go to the terminal and install the <strong>ImageMagick <\/strong>tool by typing:<\/p>\n<p><strong>sudo apt-get install imagemagick<\/strong><\/p>\n<p><strong><\/strong>Once this has been finished you can view the barcode by typing (where you replace <strong>qrcode <\/strong>with the name of your image):<\/p>\n<p><strong>display qrcode.png<\/strong><\/p>\n<p>This now displays the qrcode on the screen. You can now point the web camera to the qr code and, once it is in focus, it will read it and will display the output in the terminal.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1) How To: Raspberry PI Web Cam Server The Raspberry PI is perfectly\u00a0equipped\u00a0to 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. As a simple configuration, we will &hellip; <\/p>\n<p><a class=\"more-link block-button\" href=\"https:\/\/blog.soton.ac.uk\/pi\/trust-webcam\/\">Continue reading &raquo;<\/a><\/p>\n","protected":false},"author":84718,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-80","page","type-page","status-publish","hentry","nodate"],"_links":{"self":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/users\/84718"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":6,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages\/80\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages\/80\/revisions\/83"}],"wp:attachment":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/media?parent=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}