{"id":510,"date":"2016-12-02T19:40:49","date_gmt":"2016-12-02T19:40:49","guid":{"rendered":"http:\/\/james-batchelor.com\/?p=510"},"modified":"2016-10-31T19:46:44","modified_gmt":"2016-10-31T19:46:44","slug":"raspberry-pi-noir-camera","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2016\/12\/02\/raspberry-pi-noir-camera\/","title":{"rendered":"Raspberry Pi NoIR Camera"},"content":{"rendered":"<p>A little treat when ordering the latest Raspberry Pi was to add a camera module to it, at a price of \u00a37 for the Noir (Not French, just meaning No Infrared filter) it was easy to justify getting even if there was not a set purpose to it.<\/p>\n<p>For the price the Pi Noir camera was generous on the specs, with a 2592 x 1944, 5 Megapixel sensor it seemed capable of capturing high detail images. However, the 5Mp tagline applies to still images only, with video capped at a still respectful 1920 x 1080p.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-511\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/10\/PiCam-1024x652.jpg\" alt=\"PiCam\" width=\"840\" height=\"535\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/10\/PiCam.jpg 1024w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/10\/PiCam-300x191.jpg 300w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/10\/PiCam-768x489.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>The difference between the Noir and standard camera module is the lack of an IR filter on the lens, resulting in some washed out colours in daylight but still acceptable in a surveillance capacity, but has the ability to capture images in darkness with help of separate Infrared lighting.<br \/>\nUsing the camera module on the Pi is pretty straight forward, connecting is done via a ribbon cable plugged into a dedicated port on the Pi board.<\/p>\n<p><!--more--><\/p>\n<p>Then the module needs to be enabled in raspi-config and after a reboot it\u2019s good to go. A neat addition is that Debian Wheezy comes with two small applications that enables a user to test the camera module straight away, raspistill for stills and raspivid for video are both command line applications usable via SSH and have enough switches to satisfy most and usual features of the camera.<\/p>\n<p>So what to do with the camera? Not wanting to stretch resources on the Pi as it\u2019s already a server, the lightweight apps included with Debian can be manipulated for recording or time-lapse purposes, to keep resources down further the scheduling will be done via Cron, which gives the ability run scripts at certain intervals.<\/p>\n<h3>Setting Up Cron<\/h3>\n<p>Cron, or Crontab, comes installed on Debian Squeeze for Pi so it is ready to go, but as the program is designed to run scripts, one must be created first.<\/p>\n<p>Connect to the Pi via SSH and in the default (home) folder, create a folder called scripts by using <em>sudo mkdir scripts<\/em>. Then navigate into the folder with <em>cd scripts<\/em>.<\/p>\n<p>Create a new file called capture.sh, using <em>sudo nano capture.sh<\/em><br \/>\nEnter the following lines into the new file:<\/p>\n<blockquote><p>#!\/bin\/sh<br \/>\nDATE=$(date +&#8221;%Y-%m-%d_%H%M&#8221;)<br \/>\nraspistill -o \/media\/storage\/Camera\/$DATE.jpg<\/p><\/blockquote>\n<p>This script sets DATE variable to read the system time in the format Year-Month-Date HoursMinutes, then the raspistill program is called with an output to a folder with DATE as the filename.<\/p>\n<p><em>Ctrl + O<\/em> to save the file and <em>Ctrl + X<\/em> to exit.<\/p>\n<p>Then make the file executable so it can be used by using <em>sudo chmod +x capture.sh<\/em>.<\/p>\n<p>With the script done its time to move to the cron folder and add a file that calls the capture.sh script.<\/p>\n<p>Navigate to <em>\/etc\/cron.d<\/em><br \/>\nCreate a new file with <em>sudo nano capture<\/em><\/p>\n<p>Enter the following line:<\/p>\n<blockquote><p>* * * * * pi \/home\/james\/scripts\/capture.sh<\/p><\/blockquote>\n<p>The 5 asterisks determine when the script is run, in its current form the script will be run at the shortest possible interval which is each minute, but this can be changed to suit the user.<\/p>\n<p>From left to right, each asterisk represents a value of time; minute (0-59), hour (0-23), date (1-31), month (1-12), day (0-6 where 0 is Sunday and 6 is Saturday). So as an example 0 0 1 * * means the script would run at midnight on the 1st of every month. And to run every hour, use 0 * * * *.<br \/>\nAgain, <em>Ctrl + O<\/em> and <em>Ctrl + X<\/em> to save and exit, as soon as the file is saved the job is active and based on the system time will start on the next trigger point.<\/p>\n<p>With the capture file in the cron folder, it will run the script at the set times until the file is deleted, that\u2019s why it is a good idea to keep a copy of that file in a different location, so it can be easily copied to the cron folder when needed to run and deleted when no longer needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A little treat when ordering the latest Raspberry Pi was to add a camera module to it, at a price of \u00a37 for the Noir (Not French, just meaning No Infrared filter) it was easy to justify getting even if there was not a set purpose to it. For the price the Pi Noir camera &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2016\/12\/02\/raspberry-pi-noir-camera\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Raspberry Pi NoIR Camera&#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],"tags":[180,181,63],"class_list":["post-510","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","tag-camera","tag-noir","tag-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/510","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=510"}],"version-history":[{"count":1,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/510\/revisions"}],"predecessor-version":[{"id":512,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/510\/revisions\/512"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}