11 Replies Latest reply on Aug 9, 2014 7:14 AM by anbu369

    Connecting to camera via USB using PTP & gPhoto2


      I need to connect to a camera, Nikon Coolpix P300, to capture images and extract the image for further processing. Since this camera, like most modern cameras use PTP I found there is a library called gPhoto2 (and libgphoto2) but is not installed in the stock 0.7.5 Yocto image.


      Does anyone have an image with gPhoto2 installed? Or can someone give me instructions on how to install it myself?

        • 1. Re: Connecting to camera via USB using PTP & gPhoto2

          Hi Melvinj,


          I haven not seen a Linux image with this feature, however I can point you to basic information related to this image creation process and how add features.


          This is the link to the Quark BSP build guide where you will find information to build the image Intel® Quark BSP Build Guide  and perhaps this tutorial will give you some ideas to modify or create your own image http://www.malinov.com/Home/sergey-s-blog



          1 of 1 people found this helpful
          • 2. Re: Connecting to camera via USB using PTP & gPhoto2

            Thanks LDiego.


            I may have to build it myself as you indicated but I'll try to keep that as a last resort. I am still very inexperienced with Linux and have never even attempted to play around with the build (only apt-get in Ubuntu and playing around with certain files in Android as instructed for mods).


            Does anyone know or can get me in contact with the guy who gave the demo in Maker-Faire Rome on using Galileo with his DSLR though USB? Looks like he already has "in the bag" (If he's willing to share ).

            • 4. Re: Connecting to camera via USB using PTP & gPhoto2

              I did it! I spent 2 weeks trying to compile from source on this Linux image: https://communities.intel.com/message/228273. But just compiled flawlessly on another "heavier" Linux image by following the below procedure. Hope it helps someone.

                1. Using Yocto Project Linux image w/ Clanton-full kernel + general SDKs + OpenJDK-6 + Tomcat 7 from http://ccc.ntu.edu.tw/index.php/news/40
                2. Boot-up the Galileo board and connect via ssh
                3. Set the date date -s "17 APR 2014 14:00:00"
                4. Download libgphoto2
                5. Extract to home/root/ by bzip2 -cd libgphoto2-2.5.4.tar.bz2 | tar xvf -
                6. Go to the directory cd /libgphoto2-2.5.4
                7. Set execute attribute by chmod +x configure
                8. Run ./configure
                9. Run make
                10. Run make install
                11. Download gphoto2
                12. Extract to home/root/ by bzip2 -cd gphoto2-2.5.4.tar.bz2 | tar xvf -
                13. Copy over some files cp ~/libgphoto2-2.5.4/gphoto2/* ~/gphoto2-2.5.4/gphoto2/
                14. Set execute attribute by chmod +x configure
                15. Run ./configure
                16. Run make
                17. Run make install
                18. No errors!!!!
                19. Verify gPhoto2 is installed and working by plugging in the camera to the host USB port


              root@clanton:~/gphoto2-2.5.4# gphoto2 --version

              gphoto2 2.5.4


              Copyright (c) 2000-2014 Lutz Mueller and others


              gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of gphoto2 under the terms of the GNU General Public License. For more
              information about these matters, see the files named COPYING.


              This version of gphoto2 is using the following software versions and options:

              gphoto2         2.5.4          gcc, popt(m), no exif, no cdk, no aa, jpeg, readline

              libgphoto2      2.5.4          all camlibs, gcc, ltdl, no EXIF

              libgphoto2_port 0.10.0         gcc, ltdl, USB, serial without locking


              root@clanton:~/gphoto2-2.5.4# gphoto2 --auto-detect

              Model                          Port


              Nikon Coolpix P300 (PTP mode)  usb:002,002

              • 5. Re: Connecting to camera via USB using PTP & gPhoto2

                Hi @melvinj,


                I try to boot this heavy linux image but it won't boot on my galileo board. I am just wondering is it because I have upgraded it into the newer firmware (1.0). If that is the problem, how can I solve it? Thanks

                • 6. Re: Connecting to camera via USB using PTP & gPhoto2

                  Hi I tried following your method and my board works fine and I can control my camera using the serial cable but I want to use the USB cable to upload WiFi sketches but once booted and connected, the board is not showing up in the arduino IDE.  Thanks

                  • 7. Re: Connecting to camera via USB using PTP & gPhoto2

                    the same firmware works for me now that I upgraded to FW1.0.2. It should work. I didn't do anything special to get it to boot. You made sure to format the uSD card properly, right?

                    • 8. Re: Connecting to camera via USB using PTP & gPhoto2

                      sorry for the late reply. Unfortunately, I am currently experiencing the same issue with Arduino sketches not uploading. At least now I'm not alone and that I didn't do something to cause it! I have been running my project completely through node.js and python so I haven't had time to investigate this further. Either the code was left-out or the resource is being used by another program (most probably the latter). Tell me if you make any progress and I'll do the same. But as I said I have no need to fix this right now so it might be a while until I get around to it.

                      • 9. Re: Connecting to camera via USB using PTP & gPhoto2

                        Thanks for the reply Melvin.. I don't have the need to use any arduino sketches but since you are using the same project, is there any way I could use wifi onboard to ssh and execute the gphoto2 commands? In brief, I wish to develop a smartphone application for my college project to control the camera through the board. So any heads up on that would be appreciable. Thanks for the help.

                        • 10. Re: Connecting to camera via USB using PTP & gPhoto2

                          Sure you can. You can use puTTY to initiate an SSH session and issue commands directly. In my implementation I am using node.js to create a webserver that I use to interact with the camera. Here is a snippet of code from my app:

                          app.get('/takepicture', function (req, res) {
                            console.log("taking camera picture")
                             child = exec("gphoto2 --capture-image-and-download --force-overwrite", function (error, stdout, stderr) {
                                      console.log('stdout: ' + stdout);
                                      console.log('stderr: ' + stderr);
                                if (error !== null) 
                                  console.log('exec error: ' + error);
                                  { message: 'ERROR EXEC | taking camera |' + error }  
                                  { message: 'SUCESSFUL EXEC | taking camera | ' + stdout }  
                          • 11. Re: Connecting to camera via USB using PTP & gPhoto2

                            Thank you Melvin.. but I am not fond of node.js yet and I cannot learn it now :/ . I used the SD image from Intel and tried to access it through SSH from my iphone and it worked. now I want to install libphoto and gphoto2 in that image. But they require a lot of additional packages obviously. I successfully installed the libphoto. But gphoto2 requires popt library and popt is not installing without libicon.la which is already present in the usr/lib. I just want to know what are all the libraries I have to install in the linux image to make the gphoto2 to work and I cannot use the yocto image you referred as I couldnt ssh with wifi in that. Thanks