Showing posts with label article. Show all posts
Showing posts with label article. Show all posts

Sunday, March 13, 2011

How-to: A gphoto primer

A few years back, my time lapse video of the Portage Lake lift bridge at sunset turned out to be rather popular -- because of my brief tutorial on using gphoto2 for time-lapse video. So, I've written up a short (but more detailed) tutorial on setting up and using gphoto for time-lapse videos.

Warning! (October 2019): This post is quite out-of-date. I now use a camera with a built-in intervalometer and haven't had to wrangle gphoto2 in years. The instructions below might work -- or might not. They were last updated in March 2015.

Step 1: Install gphoto
The first step is getting gphoto installed on your computer. How exactly you do this depends on your operating system.

Mac OS X: While this isn't quite download-and-go, it is still fairly easy to install gphoto2 on Mac OS X. The first step is to install MacPorts, a package manager for Mac OS X. You can begin at the MacPorts installation page, skipping down to the "Mac OS X Package (.pkg) Installer" section. Click on the link in the first paragraph which corresponds to your system. Download, open, and run the installer. Once it is done, open a Terminal window and type:

sudo port -v selfupdate

This may take a while. Once MacPorts is done, type:

sudo port install gphoto2

this will take a while. Leave the computer alone, have some coffee, read a book. When the compiler is done, you'll have a working copy of gphoto2 and everything you need to make it work (on the computer side, at least)!

Good news for OS X programmers: In the comments, Andreas writes that he has put together a framework for Mac OS X programmers, which can be used directly in XCode. I haven't tried this myself -- and of course, always be careful with unknown code -- but if you're interested, you can find it here: https://github.com/lnxbil/GPhoto2.framework

Linux: If you are using Linux, you almost certainly know enough to install gphoto on your own -- your favorite package manager will work. Versions of gphoto2 are available for all major package managers. For example:

    sudo apt-get install gphoto2

Windows: Unfortunately for Windows users, there is no official version of gphoto for windows. In fact, the gphoto2 team has a few words to say on the matter. I have heard rumors of an unofficial version of gphoto for Windows, but finding and getting that set up is far beyond the scope of this tutorial.

Step 2: Set up and test your camera
Almost all digital cameras made in the last 10 years -- whether point-and-shoot or DSLR -- will almost certainly work with gphoto. To be sure, you can check out this complete list of supported cameras.

There are a few basic steps to getting your camera ready to work with gphoto:
  1. Set your camera to the correct connection mode. This isn't the exposure mode, but rather the mode which controls how your camera talks to your computer. To figure out which mode you need, look on the list of supported cameras. Find your camera in the list, and look for the text in parentheses at the end -- for example "(PTP mode)". You now need to change your camera into this mode. This is usually in a "setup" or "options" menu, and it's a rarely changed option. Every camera is different, and your best resource is the user's guide. Many cameras work in either their normal mode (requiring no special setup), or PTP mode, which is a standard allowing computers to control cameras.

    Here's an example for the Nikon D40x (my favorite camera) which works on most Nikon DSLRs. The mode you need is PTP mode. To set this, press the Menu button, then choose "Setup", then "USB", then "MTP/PTP" and hit OK.
  2. Connect your camera to a computer using a USB cable. This should be the normal USB cable which you use to connect your camera to your computer when downloading photos. If you normally use a card reader or some other method, you will need to locate a USB cable which lets you connect your camera directly to the computer -- typically cameras come pre-supplied with these. I recommend using a laptop, so that you can move the camera to your favorite shooting location.
  3. For Mac OS X users only: kill the PTP daemon. This isn't as evil as it sounds! Mac OS X automatically "grabs" the camera when you plug it in -- this is how iPhoto and other programs can automatically download your photos. But this also means that gphoto doesn't "own" the camera, and can't use it. To fix this, open Terminal and type:
    killall PTPCamera
    You will have to repeat this entire process every time you plug the camera in to your laptop, or if you turn the camera off and on again while attached to your computer. In fact, killing the PTP daemon is the answer to many weird gphoto errors on Mac OS X.
  4. Test that your camera is connected and working. To do so, execute this command in a terminal:
    gphoto2 --capture-image
    Your camera should (after a few seconds) take a photo, just as if you had pressed the shutter button. If it doesn't, the error message may be enlightening.

Step 3: Take photos!
You are now all ready to take photos! The most useful "advanced" feature of gphoto2 is the ability to take time-lapse photos. The basic command you need will look like this:
     gphoto2 --capture-image-and-download --interval=30 --frames=10
Here's a breakdown:
  • --capture-image: tells gphoto to take an image.
  • --interval=30 : tells gphoto to keep taking images, once every 30 seconds.
  • --frames=10 : tells gphoto to stop taking photos after 10 have been captured (leave this off to continue forever).

You can replace --capture-image-and-download with --capture-image if you want the images to be kept on the camera. (This completely fails to work on my Nikon D40x).  Remember, you don't want to touch the camera while it's taking shots!

Here are a handful of useful things to remember:
  • Your camera will take photos in the current exposure mode (Program, Aperture Priority, etc.). Be sure your camera is in the mode you want before you begin. This usually means going into full-manual mode, so that the exposure is consistent between frames. It is also possible to use gphoto2 to change your exposure mode on some cameras.
  • If using a camera with ISO-Auto, ADR, etc., turn it off. These features can change your intended exposure and make your frames look inconsistent, even if you're in fully manual exposure mode.
  • Focus your camera on the intended subject before you begin, and then turn your lens to manual focus. This will avoid the camera trying to refocus for each frame, especially if there are moving objects involved, or if lighting gets dim.
  • Don't touch your camera while taking time-lapse photos, unless you want different frames to have a different viewpoint. For time-lapse videos such as the one I mentioned at the top of this post, you want the camera to be untouched for the entire time.

Wrapup
Those are the basics! You can do a lot more than this with gphoto2 -- but that's for the future. If you're interested in seeing what you can do, there are many other tutorials available out on the web. You can also get a summary of gphoto's options by typing
   gphoto2 --help
in your terminal. For now, enjoy!


Appendix: Installing gphoto2 on Mac OS X, the hard way


For those interested in how we had to do things "back in the day", I'm keeping the information below: how to get the latest version of gphoto2 and libgphoto2 to install under Mac OS X. This is no longer necessary, because MacPorts currently has the newest version of gphoto. Read above for more information. And with that, here's the old data:

Here are more detailed instructions for installing the newest version of gphoto2 on Mac OS X. I recommend starting with the MacPorts version above -- even though it's old, installing it will also install and update many other programs which gphoto2 needs to operate. After doing that, you should get the newest version. To get the newest version, download both the gphoto and libgphoto packages from the gphoto homepage. The first step is to install libgphoto. Double-click the libgphoto package to uncompress it. In Terminal, type the following commands:
 cd (path to the libgphoto directory)
 sudo ./configure --prefix=/opt/local
A large amount of text should pass through the terminal, after which type
 sudo make
 sudo make install
This installs libgphoto. The next step is to install gphoto2 itself, which uses libgphoto to control your camera. Double-click the gphoto package to uncompress it. Again in Terminal, type the following commands:
 cd (path to the gphoto directory)
 sudo ./configure --prefix=/opt/local --without-cdk --without-aalib POPT_CFLAGS="-I${prefix}/include" POPT_LIBS="-L${prefix}/lib -lpopt"
 sudo make
 sudo make install
These should configure, compile, and install gphoto2 correctly. To double-check that it worked, type in Terminal:
 gphoto2 -v
The result should be a bit of information, including version numbers about gphoto2. If there are any errors, you'll need to reinstall gphoto2.

Wednesday, October 21, 2009

Quincy Stars - Take #2

Circular star trails with the Quincy Number 2 shaft house in the center.
Another shot at star trails at the Quincy Mine.

After my first try at star trails over the Quincy Mine, I learned many things about taking long nighttime exposures of the sky. Last Saturday, I headed back up to Quincy to put those lessons into action. In this post, I'll analyze the results, figure out what worked, what didn't, and list some more lessons learned.

Technical Details: This photo was made by "stacking" 144 separate exposures, each taken with these parameters:
  • Focal length: 10mm, on my shiny new Nikon 10-24mm
  • Shutter speed: 30 seconds
  • Aperture: f/3.5 (which was the maximum aperture available)
  • ISO: 400
I took the photos using gphoto2 (installation and details), a PTP camera controller program, installed on my MacBook Pro. The laptop controlled the camera via a USB connection. I used the gphoto2 command:
    gphoto2 --capture-image-and-download -I 34
This instructs the camera to take a photo every 34 seconds. Why 34 seconds? Interestingly, this is actually the ideal spot for my computer and camera combination to take photos at the correct rate. There is a bit of a delay when the computer instructs the camera to take the first photo. After that, gphoto2 keeps track of how far behind schedule it is -- and tries to catch up. The result is that the computer instructs the camera to take a photo after about a 1 second delay, just enough to let the sensor cool down.

Improvements and Problems: The purpose of trying this same photo shoot again was to learn from my mistakes last time. Here's a rundown of what I like and dislike about this photo.
  • Batteries and time:In many ways, this photo shoot (and the resulting star trails photo) came out much better than the last try. The major change is that my batteries -- both camera and laptop -- were fully charged. This allowed me to get much more than the mere 20 minutes of exposures which I had last time. This time, I got around 72 minutes, leading to much longer star trails.
  • gphoto Timing: Also, as mentioned above, I significantly improved the timing of the image-taking. In my previous attempt, the camera eventually got out of control (perhaps because of a "backlog" of "take a photo now!" commands), and kept taking photos without the computer being able to download them. The result was "stutters" in the star trails, as I had to reset the camera.
  • Composition and star trails: The main thing I don't like in this photo is the angle. While the shaft-rockhouse is quite dramatic, the stars are moving in circles -- much less interesting than the big ovals in the original photo. In addition, the wider angle of the star trails in the original emphasized the movement of the stars and made them appear longer.
  • Inability to take more than 30 second exposures: I still haven't found a way to both control my camera via my laptop, and take photos longer than 30 seconds. No camera control software -- whether gphoto2, Nikon Camera Control Pro, or any others -- will let me operate the camera in "bulb" mode, which allows exposures longer than 30 seconds. The result is that I have to shoot at a very wide aperture (f/3.5) which reduces depth of field, and ISO 400 which adds a lot of noise. Anyone knowing of a reasonably cheap way to take time-lapse photos with a shutter speed of longer than 30 seconds, please let me know!
  • Colors and clouds: Finally, I don't like the colors as much in this photo: the moon was new, resulting in no reflections on the shafthouse and less light in the sky. As a result, the colors of the shaft house were mostly reflections of cars and streetlights, which resulted in much less pleasing colors. In addition, clouds running through the sky resulted in brown smears in the stacked photo -- be careful to find a truly clear night!

Lessons Learned: Here's a big summary for the aspiring star-trail photographer:
  • In gphoto2, use an interval slightly longer than your exposure. This lets the camera keep up with the computer's commands, and also lets the sensor cool (avoiding weird "purple clouds" in photos.

  • Charge your batteries! ... duh.

  • Use Incandescent white balance. Unless you feel like processing 100+ RAW files, you'll need to choose a good white balance ahead of time. Incandescent white balance makes the sky appear bluer and more natural.

  • Shoot when the moon is moderately full. This helps highlight objects in the photo and adds more light in the sky, helping get more natural photos with better light balance.

  • Get there early, set up, and focus. Another big problem was that I waited until the sun was mostly down to set up my rig. As a result, focusing was difficult (and sharpness wasn't helped by the large aperture). I also had a hard time composing properly, since the viewfinder was much too dark to see through. Get to your location early, set up your equipment, focus and compose. Then set everything to manual mode and leave it until you're ready to start.

If you have any questions, feel free to leave a comment!

Tuesday, October 20, 2009

Featured on Shutter Photo!

Good news, everyone! My photos of the mining ruins in the Copper Country were recently featured on D. Travis North's excellent photography blog, Shutter Photo. The article features not only photos, but also some analysis of industrial photography and ruin hunting in general. Check it out and be sure to browse through the other articles while you're there!

Friday, April 24, 2009

Heikki's Rage

You might have heard -- we had some crazy weather up here during this past week. After a week or two of good old fashioned warm weather, most of our snow and ice were gone, and things were looking up. Well, Heikki Lunta must have thought we were getting our hopes up a little too much, and he decided to drop a few feet of snow on us. Yes, feet. Painesdale got two of them.

Inspired by this, I have developed a partial classification of Keweenaw seasons. Beginning in January, we have:
  1. Winter: you know what this is. A joyous time of snowshoeing, cool crisp nights, and enjoying the lone snow-shoveler exercise plan.
  2. Fake thaw: About 1 week in late February. Just late enough to fake you out, give you hope that winter may actually be over, and topple snow statues. A cruel joke.
  3. Winter's revenge: The return of winter after the fake thaw. Its purpose is to crush your spirit and remind you that winter is not even close to over.
  4. Thaw: This is the real deal: the end of the main part of winter. Its main characteristic is the massive melt-off of snow and ice -- filling streams and making waterfalls appear out of nowhere. Note that nothing is growing yet, and there are usually snow and ice left on the ground.


  5. Heikki's Rage: Winter's last hurrah, when Heikki Lunta throws everything he has left in one final storm. This almost always happens in the form of a blizzard or heavy, wet snowfall late in April or early in May.

  6. Spring: About one week in which flowers and all kinds of plants finally poke their heads through the ground. Almost immediately becomes...
  7. Summer: About 3 weeks months of varying degrees of heat and dryness.
  8. Fall: One cool month at the end of summer. Pleasant.
  9. Indian Summer: or, Summer's Revenge: reminding you that heat is still your enemy. This is about a week of pure hell in early October, just after the new students have started to think "well this isn't bad at all!"
  10. Autumn: When the leaves turn, and everything is beautiful, cool, and earthy for a while. It lasts all too little time.
  11. The Blahs: That in-between time when all of the leaves are down (or brown), and mother nature is trying to snow, but it just comes out as rain. Neither autumn nor winter, this is the least interesting season of the year. But eventually, we give in, and come right back to...

  12. Winter (again).

We just finished Heikki's Rage, and are quickly moving in to true Spring. The 10 inches of snow -- 21 in Painesdale -- has almost entirely melted, and it was above 60 today, just a day later! We had a couple days of very difficult driving... it seems like the snow plows were all put away for the season! But I can see buds on the trees and crocuses popping back up out of the earth, so I have no doubt that the real spring will be here soon.