Lompat ke konten Lompat ke sidebar Lompat ke footer

gPhoto Controll Camera From Linux

Konten [Tampil]
Both of the big powerhouses in the digital SLR camera market — Canon and Nikon — make software with which you can control your camera from your PC through an attached USB cable. It is a nice tool for situations when manually triggering the shutter might cause shake (such as long exposures), or for automating multiple shots at timed intervals. But, naturally, the camera makers don’t supply this software for free operating systems — and just as naturally, the open source world has an answer. You can perform the same remote operation functions using gPhoto.

The gPhoto project is one of those open source gems that works so well that it is easy to forget it is there. Plug in a digital camera, and the photo management app of your choice — be it F-Spot, digikam, gtkam, or another — identifies the camera, then quietly and expertly retrieves your photos with little to no fuss. But for most cameras, gPhoto can do considerably more, including just about any function supported by the camera’s firmware. That includes USB image capture, a function normally thought of in the context of always-attached webcams, but available for nicer digital cameras, too.
gphoto control camera

To take advantage of this feature, you must have a supported camera and (in some cases) a sufficiently recent build of gPhoto. While the basic photo upload/download capabilities of gPhoto cover close to 1,000 different camera models, not all cameras support USB camera control, and not all that do have been figured out by the gPhoto team. Check the camera control page of the project’s wiki to see if yours is on the list.

I use two cameras, a Canon S2 IS point-and-shoot, and a Canon EOS 5D SLR. Both are on the remote control supported list, although a note by the 5D indicates that gPhoto version 2.4.0 or newer is required. Since gPhoto is a standard component of most desktop Linux systems, you should be able to find an official package through your distribution; for historical reasons, the package name is gphoto2, not gphoto.

Getting started

Once I had installed a suitably recent version of gphoto2, I attached my 5D to the computer via its USB cable and switched it on. As usual, a message box popped up alerting me that a camera had been detected and asking whether I wanted to download new photos to the PC or do nothing. Plugging in your own camera might not result in such a dialog box if you have previously told your system to automatically begin extracting photos. If you cannot interrupt the photo extraction process, just wait for it to finish.

The gphoto2 package includes a command-line and ncurses-capable client program called gphoto2. You can use it to download images from the camera’s memory card if you wish, but it is also useful for querying the camera and exploring its extra features. Typing gphoto2 -a at a bash prompt will return the a list of the camera’s supported functions. For our purposes, this includes capture-image and capture-preview. The 5D does not record video or sound; cameras that do may also be capable of capture-movie and capture-sound.

At this point, gphoto2 might report that your camera is incapable of certain features (such as capture-image) that the gPhoto Web site says are supported. If that happens, the culprit is likely to be the connection mode. Some cameras (especially point-and-shoot models) can connect over USB only in Picture Transport Protocol (PTP) mode. Spiffier models may have additional modes, and depending on the model, using gphoto2 to access the advanced functions might require switching the camera into one of them.

The 5D has two options, PTP mode and “PC Connection” mode; the latter is required for remote control with gphoto2. On the 5D, at least, you can change the mode only through the camera’s built-in menus and controls via the LCD screen. Once the camera was set in PC Connection mode, gphoto2 reported capture-image and capture-preview as available functions.

Taking basic pictures

The capture-image command itself fires the shutter, just as if you’d pressed the onboard shutter release or a wired or wireless remote trigger. That means it uses the camera’s picture-taking settings — shutter speed, aperture, autofocus, resolution, and so on — as is. You must set up the shot beforehand; all gphoto2 does is send the signal to fire. Capture-image stores the resulting photo to the camera’s memory or memory card, just as with a manual shot. The only advantage you gain is the convenience of triggering the shot from the PC.

You can spice things up by adding arguments to the capture-image command. The -I or --interval argument allows you to specify an time interval, after which the camera will take additional shots. If you use -I, you should consider adding -F or --frames to specify how many shots to take in this manner. If you omit -F, gphoto2 will continue taking pictures at the specified interval until the available storage space on the camera is filled.

Some gphoto2 users have reported a bug with the capture-image command, in which the gphoto2 command does not terminate after the picture is taken. The good news is that gphoto2 has been fixed, so if your distro does not have an update yet, you can grab the source code and build it yourself if you’re hit with this bug. Otherwise, if you are at the keyboard when the problem arises, you can safely terminate gphoto2 with Ctrl-C.

In contrast to capture-image, the capture-preview command snaps a picture and downloads the result directly to the attached PC, bypassing the camera’s storage altogether. Taking advantage of this distinction allows you to snap a continuous stream of timed interval photos when combined with the -F and -I arguments, regardless of the amount of space available on the camera.

Going further

A vanilla --capture-image command fires a shot without making any adjustments. For many camera models, you can change the aperture, shutter speed, ISO settings, and other parameters with a --set-config argument. To find out which parameters gphoto2 can change on your particular camera, type gphoto2 --list-config. You can query each individual setting with gphoto2 --get-config attribute. The program will return the current value and a list of all available values, which is especially helpful for things like aperture where sophisticated cameras (or attached lenses) can have several dozen possible values that you might not have memorized. You change the setting with gphoto2 --set-config attribute value.

If all that command-line typing starts to get old, you can launch an interactive, menu-driven interface into the same settings with gphoto2 --config. This interface is text only — using ncurses — but it is more convenient than typing individual get/set commands if you have a lot of values to change.
The --hook-script option offers lots of possibilities. By adding --hook-script=/path/to/some/script.sh to the end of your --capture-image command, you tell gphoto2 to execute a shell script after the command completes. This could do anything — from rsyncing the image directory to sending you an email message.

Speaking of scripting, the command-line image capture abilities of gphoto2 are ripe for automation. Snapping a frame or two while you are at a computer that’s physically tethered to the camera has its uses. Of course you can take longer shots with reduced vibration, you can hide yourself a few feet away and snap up-close pictures of easily frightened birds, and so on. But triggering gphoto2 to capture photos based on external events — hardware- or software-driven — without your presence is a lot more interesting.

That said, I have yet to see anyone making serious real-world use of gphoto2’s scriptability in the area of remote camera control. If you know of a good example, and especially if you have firsthand experience with it, please share the details in a comment. In the meantime, find a long USB cable and start shooting.

Posting Komentar untuk "gPhoto Controll Camera From Linux"