Using the Canon Hack Development Kit

New firmware allows Canon cameras to perform some neat tricks

4 min read
Using the Canon Hack Development Kit

These aerial images of White Sands National Monument [top] and Glen Canyon Dam [middle] were taken by a Canon SD30 carried on a radio-controlled model airplane [bottom], using CHDK to operate the shutter.

David Schneider

Back in the day, hands-on photography required you to be closeted away in a darkened room, where you dunked sheets of paper into solutions of smelly chemicals. Now we manipulate photographs with software, a much less messy and oppressive process. But wouldn't it be great to have more control still—even before the photo is taken? Many cameras allow you to adjust their exposure settings manually, but that's about it. What if you could have full command of your camera's hardware?


Such thoughts motivated an anonymous programmer going by the online name VitalyB to reverse engineer the firmware for Canon's PowerShot series of digital point-and-shoot cameras. With hacker-level control, he could do things the engineers at Canon had never thought of. In 2007, he made public the fruits of his labor: the Canon Hack Development Kit, or CHDK, which Andrei Gratchev, a programmer working for eASIC Corp., of Santa Clara, Calif., and other developers have since broadened. Now you can find a version for just about any one of the Canon PowerShot series.

The CHDK firmware resides on the camera's memory card, but the original Canon firmware remains on the camera's internal flash memory. So you're not likely to "brick" your camera by using CHDK inappropriately. Indeed, you can return your camera to its stock configuration merely by restarting it without CHDK on its memory card or by switching the locking tab on the card to its unlocked position. (CHDK loads only if the card is locked, and once this firmware is loaded, the camera can still record images.) The CHDK firmware is described fully on the wiki at http://www.chdk.wikia.com, which includes a "CHDK for Dummies" section and plenty of pointers for getting up and running.

Just by loading CHDK, you'll be able to coax things out of your camera that you couldn't before—saving RAW images, for example, or getting the LCD to display the battery voltage or live histograms of pixel brightness before you shoot. But the real power of CHDK comes from its ability to run scripts on your camera. You can write your own or install ones that others have posted on the CHDK wiki.

I recently tried out one of several motion-detection scripts available there. It was written by Johan Van Barel in UBASIC. (CHDK also supports the LUA scripting language.) With it, I easily converted a Canon PowerShot A630 into what a wildlife biologist or deer hunter would call a camera trap.

Photo of a hummingbird

Terry Murphy


A CHDK motion-detection script made it possible to capture this image of a hummingbird in flight. Two off-camera flashes triggered by radio illuminated the bird and froze the rapid beating of its wings.

Most camera traps use an infrared motion detector, but a CHDK-enhanced camera can itself detect motion. Van Barel's script gives you control of such things as the delay between the motion and the shot and whether the focus is fixed or variable. Without any tuning at all of the script's parameters, I was able to get some fascinating photos of birds cavorting around the family bird feeder [see "Shutter Flutter"]. Others have used similar scripts to produce some stunning photographs of lightning.

Using another script, written by a contributor to the CHDK wiki who goes only by the name Divalent, I added what's known as an intervalometer to one of Canon's smallest cameras, the 5-megapixel SD30. I mounted the diminutive (105-gram) camera onto a radio-controlled model airplane to take aerial photos during a recent vacation to the southwestern United States. The intervalometer script allows the camera to take pictures continually at a prescribed interval—with it set at two seconds, each flight yielded a few hundred images from which I could choose a few winners.

I've just begun to explore the wealth of scripts available for CHDK. There are ones that have each press of the shutter button take a series of photos while varying the exposure, flash, zoom, focus, or sensitivity. You can even convert the USB port on your camera into an electronic shutter release. Of course, you're free to modify these scripts or write completely new ones. And really ambitious camera hackers can create their very own versions of CHDK, because the CHDK wiki includes the source code (written in C) and instructions for modifying it. With CHDK the sky's the limit, you might say.

A CHDK-enabled Canon camera can capture images that would be nearly impossible to take by pressing on the shutter button manually. These photos of birds in flight show what can be done with a motion-detection script.

This article originally appeared in print as "Camera Hacking."

This article is for IEEE members only. Join IEEE to access our full archive.

Join the world’s largest professional organization devoted to engineering and applied sciences and get access to all of Spectrum’s articles, podcasts, and special reports. Learn more →

If you're already an IEEE member, please sign in to continue reading.

Membership includes:

  • Get unlimited access to IEEE Spectrum content
  • Follow your favorite topics to create a personalized feed of IEEE Spectrum content
  • Save Spectrum articles to read later
  • Network with other technology professionals
  • Establish a professional profile
  • Create a group to share and collaborate on projects
  • Discover IEEE events and activities
  • Join and participate in discussions

From WinZips to Cat GIFs, Jacob Ziv’s Algorithms Have Powered Decades of Compression

The lossless-compression pioneer received the 2021 IEEE Medal of Honor

11 min read
Vertical
Photo of Jacob Ziv
Photo: Rami Shlush
Yellow

Lossless data compression seems a bit like a magic trick. Its cousin, lossy compression, is easier to comprehend. Lossy algorithms are used to get music into the popular MP3 format and turn a digital image into a standard JPEG file. They do this by selectively removing bits, taking what scientists know about the way we see and hear to determine which bits we'd least miss. But no one can make the case that the resulting file is a perfect replica of the original.

Not so with lossless data compression. Bits do disappear, making the data file dramatically smaller and thus easier to store and transmit. The important difference is that the bits reappear on command. It's as if the bits are rabbits in a magician's act, disappearing and then reappearing from inside a hat at the wave of a wand.

Keep Reading ↓Show less