{"id":2156,"date":"2017-06-22T15:47:08","date_gmt":"2017-06-22T15:47:08","guid":{"rendered":"http:\/\/www.daveakerman.com\/?p=2156"},"modified":"2017-06-22T15:47:08","modified_gmt":"2017-06-22T15:47:08","slug":"pi-in-the-sky-photography","status":"publish","type":"post","link":"http:\/\/www.daveakerman.com\/?p=2156","title":{"rendered":"Pi In The Sky Photography"},"content":{"rendered":"<p>I&#8217;ve had a few emails asking how to get camera images off of the PITS SD card, and have seen flights appear on the live image page with poorly configured image settings, so I&#8217;m going to cover both of these subjects in this article.<\/p>\n<h1>Image Configuration<\/h1>\n<p>The image-taking is quite flexible, and the software comes pre-configured with options that are suitable for the majority of flights, but still you may wish to adjust the settings yourself.<\/p>\n<h2>Image Taking<\/h2>\n<p>The camera is controlled by a script (~\/pits\/tracker\/camera) which runs a basic loop to take photos for the radio transmitter and also for permanent storage. \u00a0The script looks for an runs separate small scripts for the RTTY channel (the standard transmitter on the PITS board), for LoRa (if you have the LoRa add-on board) and for permanent storage but not transmission. \u00a0These small scripts are created by the main tracker program (~\/pits\/tracker\/tracker) according to settings in the configuration file (\/boot\/pisky.txt). \u00a0There is some basic information in the manual and <a href=\"http:\/\/www.pi-in-the-sky.com\/index.php?id=configuration\">online<\/a>\u00a0but I will \u00a0go into more depth here.<\/p>\n<p>The camera software uses a simple scheduler to take a photograph of a certain resolution every\u00a0<em>n<\/em> seconds. \u00a0The resolution can be set separately for low or high altitudes &#8211; there&#8217;s no point in transmitting large images before the balloon is launched!<\/p>\n<p>There are several such schedules running independently, so you can separately control the rate of image taking for RTTY, LoRa etc. \u00a0This is useful because for example LoRa typically transmits data more quickly than RTTY does, so you might want there to be more frequent LoRa images than RTTY.<\/p>\n<h2>Transmission<\/h2>\n<p>The next thing to remember is that although it&#8217;s possible to take a photograph every few seconds, it takes a\u00a0<strong>lot<\/strong> longer to transmit them. \u00a0The transmission time depends on various factors but the main one under your control is of course the image size in pixels; do not make the mistake of one team who used images so large that it didn&#8217;t have time to fully transmit even one image!<\/p>\n<p>Since it is possible to take images much more quickly than transmit them, the software is able to choose what it considers to be the &#8220;best&#8221; of recent images for transmission. \u00a0Suppose that it takes 5 minutes to transmit an image, and one us taken every 30 seconds; that gives the software 10 images to choose from. \u00a0The &#8220;algorithm&#8221; (if I can call it that) is to simply select the largest JPG file out of those images, and this works surprisingly well in selecting good images and not selecting poor ones (e.g. those pointing at the black sky above).<\/p>\n<p>Having selected a image to transmit, that image and all the ones it rejected are moved to a dated folder, so they aren&#8217;t later considered for transmission. \u00a0This means that (using the above example) the next image will be chosen from the next 10 photographs. \u00a0So, at any point, the transmitted image will only be a few minutes old.<\/p>\n<p>Since images are sent using the same radio transmitter(s) as telemetry, only one or the other can be sent at any one time on a particular transmitter. \u00a0So, the software interlaces image data and telemetry, which means that it will send a certain number of image packets, then a telemetry packet, and then repeat the cycle. \u00a0The ratio can be fairly high when the balloon is high &#8211; we don&#8217;t \u00a0need frequent telemetry updates at that time &#8211; but is forced to be 1:1 at lower altitudes (so we get frequent position updates as the balloon comes in to land).<\/p>\n<h2>Configuration<\/h2>\n<h3>High and Low<\/h3>\n<p>As I mentioned, the software can use different image sizes for low altitude and high altitude, with the changeover controlled by this line in the configuration file:<\/p>\n<pre>high=2000<\/pre>\n<p>So, above 2000m the software uses settings for &#8220;high&#8221; images, and below that it uses those for &#8220;low&#8221; images. \u00a0The same changeover altitude is used for all image channels (RTTY, LoRa and &#8220;FULL&#8221; for SD card only) and each channel has separate settings for high and low image sizes.<\/p>\n<h3>RTTY Images<\/h3>\n<p>You can set the image size for low or high images, plus how often images are taken, plus the ratio of image packets to telemetry packets (when above the &#8220;high&#8221; setting above):<\/p>\n<pre>low_width=320\r\nlow_height=240\r\nhigh_width=640\r\nhigh_height=480\r\n\r\nimage_packets=4\r\n\r\nimage_period=60<\/pre>\n<p>When the tracker program starts and reads this file, it displays the following in response, explaining what the options do:<\/p>\n<pre>RTTY Low image size 320 x 240 pixels\r\nRTTY High image size 640 x 480 pixels\r\nRTTY: 1 Telemetry packet every 4 image packets\r\nRTTY: 60 seconds between photographs<\/pre>\n<p>For typical 300 baud RTTY (the default speed for RTTY in PITS), this provides an image every few minutes, which is fine. \u00a0Images will be transmitted more often at high altitude because the black sky compresses very well, which helps. \u00a0I do not recommend using larger image sizes for RTTY. \u00a0Also,\u00a0<strong>do not<\/strong> transmit images at all if you are using 50 baud (set image_period=0 to disable images for RTTY).<\/p>\n<h3>Full Size Images for SD Card Only<\/h3>\n<p>Since these images are not transmitted, they might as well be set to the full camera resolution when above the &#8220;high&#8221; setting:<\/p>\n<pre>full_low_width=640\r\nfull_low_width=480\r\nfull_high_width=2592\r\nfull_low_width=1944\r\nfull_image_period=60<\/pre>\n<p>Which results in the following output:<\/p>\n<pre>Full Low image size 640 x 480 pixels\r\nFull High image size 2592 x 1944 pixels\r\nFull size: 60 seconds between photographs<\/pre>\n<h3>LoRa Images<\/h3>\n<p>For LoRa, remember to specify the LoRa channel (0 or 1, for CE0 or CE1, according to which position(s) are occupied on your LoRa board). \u00a0Settings are very similar to those for RTTY:<\/p>\n<pre>LORA_low_width_0=320\r\nLORA_low_height_0=240\r\nLORA_high_width_0=640\r\nLORA_high_height_0=480\r\nLORA_image_packets_0=4\r\nLORA_image_period_0=60<\/pre>\n<p>LoRa transmissions should be set to mode 1 (see the LoRa section in the manual) as this is the best option for imaging. \u00a0The resulting speed is about 4 times that for 300 baud RTTY, so you will get more frequent updates, or you could increase the image sizes.<\/p>\n<pre>LORA0 Low image size 320 x 240 pixels\r\nLORA0 High image size 640 x 480 pixels\r\nLORA0: 1 Telemetry packet every 4 image packets\r\nLORA0: 60 seconds between photographs<\/pre>\n<h3>Other Settings<\/h3>\n<p>If you don&#8217;t want images at all, either simply remove the camera, or disable the software from using it with:<\/p>\n<pre>camera=N<\/pre>\n<p>Assuming use of a Pi camera, the software uses the raspistill program to take photographs. \u00a0You can add parameters that are passed to raspistill, which is handy if for example the camera is upside-down (happens&#8230;). \u00a0To do this, first check the online raspistill documentation, and then add your parameters using &#8220;camera_settings&#8221; e.g.:<\/p>\n<pre>camera_settings=-vf -hf<\/pre>\n<p>which does vertical and horizontal flips to rotate the image by 180 degrees.<\/p>\n<p>&nbsp;<\/p>\n<h1>Images From SD Card<\/h1>\n<p>So, you&#8217;ve flown your flight, recovered the payload, and want to get those images from the SD card onto another computer. \u00a0There are many methods:<\/p>\n<ul>\n<li>If you have a PC or Pi running Linux, you can pop the SD card into a card reader, and access the files directly<\/li>\n<li>With a Windows PC, and a card reader, you can use\u00a0<a href=\"https:\/\/www.diskinternals.com\/linux-reader\/\">SysInternals Linux Reader<\/a>\u00a0to access the files.<\/li>\n<li>If you connect the Pi to a network, you can use WinSCP to access files from a Windows PC on the same network.<\/li>\n<li>Or, also with the Pi on a network, you can install SAMBA on the Pi to share it&#8217;s files.<\/li>\n<\/ul>\n<p>Here we will cover the WinSCP option.<\/p>\n<h2>WinSCP<\/h2>\n<p>First, install WinSCP from the <a href=\"https:\/\/winscp.net\/eng\/download.php\">official page<\/a>. \u00a0Start the program and you will see this initial screen; enter the IP address of the Pi (which it displays on the monitor at the end of the boot process) and the Pi user name (&#8220;pi&#8221;). \u00a0Click Save to save the settings.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2162\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp1.jpg\" alt=\"\" width=\"646\" height=\"437\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp1.jpg 646w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp1-300x203.jpg 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/p>\n<p>Then click Login and the program will connect to the Pi, requesting a password (even you entered one above!):<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2166\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp5.jpg\" alt=\"\" width=\"395\" height=\"313\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp5.jpg 395w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp5-300x238.jpg 300w\" sizes=\"(max-width: 395px) 100vw, 395px\" \/><\/p>\n<p>and then, again if this is the first time you&#8217;ve connected to the Pi, it will ask for confirmation:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2164\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp3.jpg\" alt=\"\" width=\"482\" height=\"293\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp3.jpg 482w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp3-300x182.jpg 300w\" sizes=\"(max-width: 482px) 100vw, 482px\" \/><\/p>\n<p>Once connected, you will see a file manager window with the directory structure on the left, and any files on the right:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2167\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp6.jpg\" alt=\"\" width=\"731\" height=\"520\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp6.jpg 731w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp6-300x213.jpg 300w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/p>\n<p>Now, select the images directory (home\/pi\/pits\/tracker\/images) and you will see the following directories:<\/p>\n<ul>\n<li>FULL &#8211; for the full-sized images<\/li>\n<li>LORA0 &#8211; for LoRa CE0 images<\/li>\n<li>LORA1 &#8211; for LoRa CE1 images<\/li>\n<li>RTTY &#8211; for RTTY images<\/li>\n<\/ul>\n<p>Choose whichever you like, and you will then see dated directories within:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2168\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp7.jpg\" alt=\"\" width=\"732\" height=\"603\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp7.jpg 732w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp7-300x247.jpg 300w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><\/p>\n<p>Open up whichever matches the date of your flight, and you will (hopefully!) see lots of image files:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2169\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp8.jpg\" alt=\"\" width=\"731\" height=\"603\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp8.jpg 731w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2017\/06\/scp8-300x247.jpg 300w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/p>\n<p>You can drag individual files, multiple files or even entire directories to your hard drive or any other storage.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve had a few emails asking how to get camera images off of the PITS SD card, and have seen flights appear on the live image page with poorly configured image settings, so I&#8217;m going to cover both of these subjects in this article. Image Configuration The image-taking is quite [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2156"}],"collection":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2156"}],"version-history":[{"count":6,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2156\/revisions"}],"predecessor-version":[{"id":2170,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2156\/revisions\/2170"}],"wp:attachment":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2156"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}