{"id":658,"date":"2020-04-07T18:10:16","date_gmt":"2020-04-07T18:10:16","guid":{"rendered":"http:\/\/james-batchelor.com\/?p=658"},"modified":"2020-04-07T18:10:16","modified_gmt":"2020-04-07T18:10:16","slug":"working-from-home-pi-camera-as-windows-webcam","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2020\/04\/07\/working-from-home-pi-camera-as-windows-webcam\/","title":{"rendered":"Working From Home \u2013 Pi Camera as Windows Webcam"},"content":{"rendered":"\n<p>Hopefully the mad dash for home working is over, and now\neveryone who can has settled in to a comfortable home setup with new knowledge\nof what a VPN and remote desktops are all about.<\/p>\n\n\n\n<p>I thought my established home setup was great, however I\ndidn\u2019t envisage words like Teams and Zoom to become the buzzwords of companies\nthe world over.<\/p>\n\n\n\n<p>This posed an issue for myself. Even though my 2017 Dell XPS\nhas a webcam ready to go, it spends its home office days docked with the lid\nclosed. When opening the 4K screen combined with the Full HD monitors, Windows\nimplementation of scaling rears is appalling head and just looks terrible.\nCombined with the Dell\u2019s decision to locate the webcam below the screen to give\nmaximum nostril-cam angle, its not something I like to use.<\/p>\n\n\n\n<p>Buying a USB webcam didn\u2019t seem worth it for what is\n(hopefully at time of writing) a temporary solution. <\/p>\n\n\n\n<p>So in comes another Pi project, this time using a spare Raspberry Pi Camera module connected to an aptly placed Pi, that can be used on a Windows machine for the software likes of Zoom, Skype and Teams\u2026<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"606\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/20200407_1610401.jpg\" alt=\"\" class=\"wp-image-663\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/20200407_1610401.jpg 800w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/20200407_1610401-300x227.jpg 300w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/20200407_1610401-768x582.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure><\/div>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Pi Setup<\/strong><\/h3>\n\n\n\n<p><strong>Enable Camera<\/strong><\/p>\n\n\n\n<p>Using a fresh install of Raspbian Buster, locate and login\nto SSH of the Pi and run the configuration utility:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo raspi-config<\/pre>\n\n\n\n<p>In the menu, navigate to 5. Interfacing Options, then P1 Camera, and enable.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"418\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture00.png\" alt=\"\" class=\"wp-image-664\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture00.png 661w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture00-300x190.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p>Navigate back to the main menu and Enter on Finish, select\nYes if prompted to reboot.<\/p>\n\n\n\n<p><strong>Set Static IP<\/strong><\/p>\n\n\n\n<p>The camera will be accessed over the network, so makes life\neasier and more reliable for it to always be found on the network in the same\nlocation. In an SSH session, enter:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo nano \/etc\/dhcpcd.conf<\/pre>\n\n\n\n<p>Scroll to the bottom of the page and enter the following:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">static ip_address={IP ADDRESS}\/24<br>static routers={ROUTER ADDRESS}<br>static domain_name_servers={ROUTER ADDRESS}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"271\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture01alt.png\" alt=\"\" class=\"wp-image-665\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture01alt.png 661w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture01alt-300x123.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p><strong>Install Software<\/strong><\/p>\n\n\n\n<p>The software I\u2019d prefer for this task is <a rel=\"noreferrer noopener\" aria-label=\"MJPEG Streamer (opens in a new tab)\" href=\"https:\/\/github.com\/jacksonliam\/mjpg-streamer\" target=\"_blank\">MJPEG Streamer<\/a>, a lightweight camera image generator that has come to my aid when <a href=\"https:\/\/james-batchelor.com\/index.php\/2019\/08\/10\/libreelec-pi-camera-mjpeg-streaming\/\">setting up a CCTV system<\/a>. <\/p>\n\n\n\n<p>Start with installing the dependencies:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo apt-get install build-essential imagemagick libv4l-dev\nlibjpeg-dev cmake<\/pre>\n\n\n\n<p>Download the MJPEG Streamer files from git:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">git clone https:\/\/github.com\/jacksonliam\/mjpg-streamer.git<\/pre>\n\n\n\n<p>Navigate the folder in order to compile:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">cd mjpg-streamer\/mjpg-streamer-experimental<\/pre>\n\n\n\n<p>Then compile:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">make<\/pre>\n\n\n\n<p>No errors? Go and install it:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo make install<\/pre>\n\n\n\n<p>This will install the program, and leave you at the command\nline with little fanfare\u2026<\/p>\n\n\n\n<p><strong>Testing<\/strong><\/p>\n\n\n\n<p>Sanity check, and time to see if the software will work,\nfrom the command line run the following:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">\/usr\/local\/bin\/mjpg_streamer -i \"input_uvc.so -r\n1280x720 -d \/dev\/video0 -f 30\" -o \"output_http.so -p 8080 -w\n\/usr\/local\/share\/mjpg-streamer\/www\"<\/pre>\n\n\n\n<p>These are the common variables should you need to adjust anything\nto get started:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">-r 1280x720 \u2013 Set stream output resolution<br>-f 30 \u2013 Framerate<br>-p 8080 \u2013 Port the stream binds to<\/pre>\n\n\n\n<p>From another PC, open a browser and navigate to <em>http:\/\/{IP ADDRESS}:8080\/?action=stream<\/em> where <em>{IP ADDRESS}<\/em> is that of the Raspberry Pi.<\/p>\n\n\n\n<p><strong>Launch at Startup<\/strong><\/p>\n\n\n\n<p>You may notice when testing the above test command that it\noccupies the command line whilst running, and doesn\u2019t allow any other tasks,\nexiting the program by using Ctrl + C also stops the video stream. <\/p>\n\n\n\n<p>Therefore its more convenient to have the camera stream\nstart when the Pi starts, and have it run unhindered in the background to give\neasy access to the Windows machine.<\/p>\n\n\n\n<p><strong>Script File<\/strong><\/p>\n\n\n\n<p>Before it can start automatically, the command needs to be\nwrapped in a script file and executed:<\/p>\n\n\n\n<p>Open a new text file with nano, located in the Pi (Default\nuser) home directory:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo nano \/home\/pi\/camstart.sh<\/pre>\n\n\n\n<p>Paste the command tested above into the file, then save and\nexit with Ctrl+O and Ctrl+X<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"111\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture02.png\" alt=\"\" class=\"wp-image-666\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture02.png 661w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture02-300x50.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p>This file needs to be executed, so give it execute\npermissions:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo Chmod +x \/home\/pi\/camstart.sh<\/pre>\n\n\n\n<p>Script made, it needs to be run at boot, this can be done\nwith cron:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo crontab -e<\/pre>\n\n\n\n<p>Enter the following on a new line at the bottom of the file:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">@reboot \/home\/pi\/camstart.sh<\/pre>\n\n\n\n<p>Use Ctrl+O and Ctrl+X to save and exit.<\/p>\n\n\n\n<p>Now to see if it worked, restart the Pi gracefully with:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">sudo shutdown -r now<\/pre>\n\n\n\n<p>When it re-appears, visit http:\/\/{IP ADDRESS}:8080\/?action=stream again\nand see if you have a live stream.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Windows Setup<\/strong><\/h3>\n\n\n\n<p>Now the camera is setup and broadcasting the image over the\nlocal network, we need something on the windows machine to capture and convert\nit and make it recognisable by video conferencing software.<\/p>\n\n\n\n<p>There are a number of applications that can achieve this,\nbut often it is an addon to a much larger software suite and would be considered\nto be bloatware to what we want to achieve.<\/p>\n\n\n\n<p>Cue IP Camera Adapter 3.1 <a href=\"https:\/\/ip-webcam.appspot.com\/\">https:\/\/ip-webcam.appspot.com\/<\/a> as a\nlightweight application that has just does the conversion process and nothing\nelse.<\/p>\n\n\n\n<p>Run the setup wizard and upon installation, run the\n\u201cConfigure IP Camera Adapter\u201d from the start menu:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"225\" height=\"79\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture08.png\" alt=\"\" class=\"wp-image-670\"\/><\/figure><\/div>\n\n\n\n<p>Enter <em>http:\/\/{IP ADDRESS}:8080\/?action=stream<\/em> into the URL field.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"454\" height=\"285\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture04.png\" alt=\"\" class=\"wp-image-667\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture04.png 454w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture04-300x188.png 300w\" sizes=\"auto, (max-width: 454px) 85vw, 454px\" \/><\/figure><\/div>\n\n\n\n<p>And test the link by pressing <em>Autodetect<\/em>, the message with tell you if it was successful:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"310\" height=\"128\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture05.png\" alt=\"\" class=\"wp-image-668\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture05.png 310w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture05-300x124.png 300w\" sizes=\"auto, (max-width: 310px) 85vw, 310px\" \/><\/figure><\/div>\n\n\n\n<p><strong>Final Testing<\/strong><\/p>\n\n\n\n<p>From here the camera should be available on most video\nsoftware, you will just have to update it to use the newly added camera, this\nwill be labelled as MJPEG Camera:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"423\" height=\"99\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture06.png\" alt=\"\" class=\"wp-image-669\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture06.png 423w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2020\/04\/Capture06-300x70.png 300w\" sizes=\"auto, (max-width: 423px) 85vw, 423px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hopefully the mad dash for home working is over, and now everyone who can has settled in to a comfortable home setup with new knowledge of what a VPN and remote desktops are all about. I thought my established home setup was great, however I didn\u2019t envisage words like Teams and Zoom to become the &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2020\/04\/07\/working-from-home-pi-camera-as-windows-webcam\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Working From Home \u2013 Pi Camera as Windows Webcam&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,97],"tags":[284,161,281,282,63,287,286,283,285],"class_list":["post-658","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","category-windows","tag-home-working","tag-ip-camera","tag-pi-4","tag-pi-camera","tag-raspberry-pi","tag-skype","tag-teams","tag-webcam","tag-zoom"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/comments?post=658"}],"version-history":[{"count":5,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/658\/revisions"}],"predecessor-version":[{"id":672,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/658\/revisions\/672"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}