{"id":1994,"date":"2016-11-11T14:04:25","date_gmt":"2016-11-11T14:04:25","guid":{"rendered":"http:\/\/www.daveakerman.com\/?p=1994"},"modified":"2016-11-11T23:30:26","modified_gmt":"2016-11-11T23:30:26","slug":"raspberry-pi-ssdv-with-a-compact-camera-or-slr","status":"publish","type":"post","link":"http:\/\/www.daveakerman.com\/?p=1994","title":{"rendered":"Raspberry Pi SSDV with a Compact Camera or SLR"},"content":{"rendered":"<p>Many HAB flights now use SSDV to transmit images &#8220;live&#8221; from the balloon down to the ground, using a camera connected to the flight computer, providing an immediacy that is missing when just flying standalone cameras. \u00a0Early SSDV flights used serial cameras connected to a microcontroller, but image quality (and, ease of programming) took a step forward when the Raspberry Pi arrived with simple access to webcams. \u00a0<a href=\"http:\/\/www.daveakerman.com\/?p=592\">My first SSDV flight<\/a>\u00a0and the following 3 used a webcam, sending SSDV down over RTTY.<\/p>\n<figure style=\"width: 432px\" class=\"wp-caption alignnone\"><img decoding=\"async\" loading=\"lazy\" class=\"size-large\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2012\/07\/2012-07-14-14-30-54-PIE1-1F.jpeg\" alt=\"PIE1 SSDV Image\" width=\"432\" height=\"240\" \/><figcaption class=\"wp-caption-text\">PIE1 SSDV Image<\/figcaption><\/figure>\n<p>Webcams do not provide great image quality, which then improved when the Raspberry Pi camera came out. \u00a0There was also some <a href=\"http:\/\/chris-stubbs.co.uk\/wp\/?p=375\">excellent work<\/a>\u00a0by Chris Stubbs who managed to program a Canon compact camera to send SSDV directly, again over RTTY.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-1995\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/9579985600_fd8ee86cf4_b-1024x576.jpg\" alt=\"9579985600_fd8ee86cf4_b\" width=\"640\" height=\"360\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/9579985600_fd8ee86cf4_b.jpg 1024w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/9579985600_fd8ee86cf4_b-300x169.jpg 300w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/9579985600_fd8ee86cf4_b-768x432.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>With RTTY we are limited to sending quite small images &#8211; around 500&#215;300 pixels &#8211; because larger images take too long to transmit. \u00a0 It is possible to increase the speed from 300 baud to 600, though it then becomes more difficult to receive, or by using the trick of multiple RTTY transmitters on the same tracker, such as this one:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2013\/05\/P1070798-1024x682.jpg\" alt=\"\" width=\"1024\" height=\"682\" \/><\/p>\n<p>Another option though is to replace RTTY with LoRa, which on 434MHz provides a speed increase of about 4x over typical RTTY speeds, and that increases by another tenfold if using 868MHz (all due to varying bandwidth limits allowed within IR2030). \u00a0Further, LoRa allows for uploads to repeat any missing packets, and this in the 868MHz band produces some impressive results (the inset is an image from my first Pi SSDV flight, showing the improvement we now have in quality and resolution):<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/pbs.twimg.com\/media\/CeT0zyhXEAAjEOo.jpg:large\" alt=\"\" width=\"1024\" height=\"768\" \/><\/p>\n<p>So, these bandwidths allow us to send rather higher quality images than before, to the point that the image compression is limiting quality. \u00a0With this in mind, Philip Heron added a quality setting to his excellent <a href=\"https:\/\/github.com\/fsphil\/ssdv\">SSDV encoder\/decoder<\/a>\u00a0to control the amount of compression applied.<\/p>\n<p>With reduced image compression and higher bandwidths, the remaining factor is camera quality. \u00a0Whilst the Raspberry Pi cameras (especially the newer Sony) are quite good, they do have tiny sensors and simple plastic lenses. \u00a0A step up would be to use a compact camera, mirrorless system camera or an SLR. \u00a0These also potentially offer wider angle lens, making for more impressive HAB photographs. \u00a0However we need to get those images to the flight computer.<\/p>\n<p>Pretty much every modern camera allows for a USB\u00a0PTP (Picture Transfer Protocol) connection to a computer, allowing it to be controlled by a computer to a greater or lesser extent. \u00a0For most cameras all we get to do is download images from the camera &#8211; and that&#8217;s all that most people need &#8211; but we also need to be able to take images under control of our flight computer.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-1998\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/IMG_2884-683x1024.jpg\" alt=\"img_2884\" width=\"640\" height=\"960\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/IMG_2884-683x1024.jpg 683w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/IMG_2884-200x300.jpg 200w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/IMG_2884-768x1152.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>To take and transfer images we can use the Linux program <a href=\"http:\/\/www.gphoto.org\/\">gphoto2<\/a>, with a compatible camera that includes remote operation (i.e. ability to take an image via a command on the Pi). \u00a0The\u00a0<a href=\"http:\/\/www.gphoto.org\/doc\/remote\/\">compatibility list<\/a>\u00a0includes few modern compact cameras, as the remote functions are typically only available on SLRs. \u00a0Canon, for example, used to include remote capture in their Powershot models but stopped this practice in 2009, presumably to persuade people to buy their SLRs instead. \u00a0I tested with an old Canon SLR (EOS 400D) and pretty much every function is supported &#8211; remote shooting, control of ISO, control of aperture\/shutter (if the camera is set to semi-auto or manual mode). \u00a0However I&#8217;m not specially keen on flying something as heavy and solid as an SLR with wide-angle lens, so I checked the compatibility list for smaller, lighter alternatives. \u00a0Sadly none of my other cameras fitted the bill, so I purchased a <a href=\"http:\/\/www.photographyblog.com\/reviews\/nikon_coolpix_s3300_review\/\">Nikon S3300 compact<\/a>. \u00a0This provides remote shooting (albeit without any control over aperture etc.), has a wide-angle lens (26mm equivalent for 35mm sensors), 16MP sensor, is small and light, and charges from USB (so the Pi should be able to keep it charged during flight).<\/p>\n<p>Once gphoto2 has been installed (sudo apt-get install gphoto2), then the first thing to do is connect the camera and check that it can bee seen:<\/p>\n<pre>gphoto2 --auto-detect<\/pre>\n<p>This should produce a result like this:<\/p>\n<pre>Model Port\r\n----------------------------------------------------------\r\nNikon Coolpix S3300 (PTP mode) usb:001,012<\/pre>\n<p>So far so good. \u00a0Now to find out what capabilities the camera offers:<\/p>\n<pre>gphoto2 --summary<\/pre>\n<p>Which will give you something like this (some parts removed):<\/p>\n<pre>Camera summary:\r\nManufacturer: Nikon Corporation\r\nModel: S3300\r\n Version: COOLPIX S3300 V1.0\r\nVendor Extension ID: 0xa (1.0)\r\nVendor Extension Description: microsoft.com: 1.0;\r\n\r\nCapture Formats: JPEG\r\nDisplay Formats: Association\/Directory, Defined Type, JPEG, DPOF, MS AVI, Apple Quicktime, MS Wave\r\n\r\nDevice Capabilities:\r\n File Download, File Deletion, File Upload\r\n Generic Image Capture, No Open Capture, No vendor specific capture\r\n\r\nDevice Property Summary:\r\nProperty 0xd407:(read only) (type=0x6) 1\r\nProperty 0xd406:(readwrite) (type=0xffff) ''\r\nProperty 0xd002:(readwrite) (type=0x6) Enumeration [1,2,3,4,5,6,7] value: 6\r\nDate &amp; Time(0x5011):(readwrite) (type=0xffff) '20161111T143911'\r\nFlash Mode(0x500c):(readwrite) (type=0x4) Enumeration [1,2,3,4] value: Flash off (2)\r\nFocus Mode(0x500a):(readwrite) (type=0x4) Enumeration [2,3] value: Automatic (2)\r\nFocal Length(0x5008):(read only) (type=0x6) Enumeration [3500,4600,5300,6100,7300,8600,10500] value: 35 mm (3500)\r\nBattery Level(0x5001):(read only) (type=0x2) Enumeration [2,5,25,50,65,80,100] value: 80% (80)\r\nProperty 0xd303:(read only) (type=0x2) 1<\/pre>\n<p>Form this we can see that the camera supports &#8220;Generic Image Capture&#8221; (woohoo!) but no control over zoom (focal length is read-only). \u00a0Given that for a HAB flight I want the lens at its default widest setting anyway, that&#8217;s not an issue.<\/p>\n<p>Taking a photo is simple:<\/p>\n<pre>gphoto2 --capture-image-and-download --force-overwrite --filename dave.jpg<\/pre>\n<p>This will extend the lens if it&#8217;s retracted, focus the lens, set the exposure (using whatever options are set within the camera), take a photograph and then download it to the Pi.<\/p>\n<p>For more advanced cameras you may be able to control the exposure manually (aperture and\/or shutter), control the ISO etc. \u00a0The available settings, and the specific commands to set them, vary from camera to camera but your starting point should be to list them all:<\/p>\n<pre>gphoto2 --list-config<\/pre>\n<p>The latest version of the <a href=\"https:\/\/github.com\/PiInTheSky\/pits\">Pi In The Sky software<\/a>\u00a0includes options for the use of cameras via gphoto2 (see instructions in the README). \u00a0With &#8220;Camera=G&#8221; in the pisky.txt file, gphoto2 and imagemagick installed, and a compatible camera connected and powered on, then PITS should take images on that camera and transmit them via SSDV.<\/p>\n<p>Unlike with the Pi camera, images are taken at full resolution (or whatever resolution is set within the camera), and are then stored on the Pi SD card at that resolution. \u00a0The resizing for transmission is then done by imagemagick, which is why that has to be installed.<\/p>\n<p>In testing, the Nikon has been completely reliable, running for 11 hours continuously till eventually the battery was discharged (remember, it charges to some degree over over USB hence the long run time). \u00a0So this is looking good for a flight. \u00a0Here&#8217;s a sample test image as sent via SSDV\/LoRa.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-1997\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/2016-11-11-12-18-35-NIKON2-B3EA-1024x768.jpeg\" alt=\"2016-11-11-12-18-35-nikon2-b3ea\" width=\"640\" height=\"480\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/2016-11-11-12-18-35-NIKON2-B3EA-1024x768.jpeg 1024w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/2016-11-11-12-18-35-NIKON2-B3EA-300x225.jpeg 300w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/2016-11-11-12-18-35-NIKON2-B3EA-768x576.jpeg 768w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2016\/11\/2016-11-11-12-18-35-NIKON2-B3EA.jpeg 1536w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many HAB flights now use SSDV to transmit images &#8220;live&#8221; from the balloon down to the ground, using a camera connected to the flight computer, providing an immediacy that is missing when just flying standalone cameras. \u00a0Early SSDV flights used serial cameras connected to a microcontroller, but image quality (and, [&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\/1994"}],"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=1994"}],"version-history":[{"count":5,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1994\/revisions"}],"predecessor-version":[{"id":2002,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1994\/revisions\/2002"}],"wp:attachment":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1994"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}