HOWTO: Automate One-A-Day Photography

This will be a somewhat unusual HOWTO compared to those typically on this site.  In an effort to lose weight, I decided I wanted to take a photo of myself, once per day so I could track and further motivate the progress of regular exercise.  I then wanted to overlay the date each photo was taken as well as my weight on that day.  Finally, I wanted animate these daily photos into a GIF and upload it to my website so I can remind myself anywhere of my objective of losing weight.  The trick is I wanted to automate this entire process.  This meant I needed to find a solution for the following:

  1. Remotely control my camera to be able to take a picture and download it from an automated script
  2. Be able to programmatically crop the image from the camera to remove everything except the white background and myself
  3. Have a mechanism to be able to overlay text onto an existing image so I can add the current date any my weight data
  4. Obtain my latest weight from my Garmin Index scale via Garmin Connect and append it to the image
  5. Combine all of the previous images into an animated gif so I can watch my progress
  6. Automatically upload the animated gif to my website so I can view it anywhere

To complete this project, I decided to try and leverage my Canon S100 which I purchased as Canon’s top-end prosumer camera in 2012.  As I researched my options however, I discovered that Canon disabled any kind of remote control capabilities for this camera.  Fortunately I discovered that some very smart people created an alternative firmware for many popular Canon cameras including mine.  This firmware is called the CHDK or “Canon Hackers Developer Kit”.  This provides all sorts of additional features that are otherwise only available in Canon’s DSLR professional series cameras.  The one that I’m most interested in however is that the firmware provided the option to remote control my Canon S100.

Once I had the new firmware installed on my camera, I then obtained a software called CHDKPTP which is what I will use to actually control the camera.  In order for it to work with the custom firmware however, I had to first install a custom USB driver that would allow for direct access between the camera and the computer.

With the ability to now programmatically control my camera, I then leveraged a free tool called “convert.exe” from ImageMagik that allowed me to crop the incoming images, add custom overlay text and convert the end product into GIF files which can then be animated.  Finally I found a tool called gifsicle that can take a series of gif files and animate them together.  I then used to upload the final GIF file to my website using SFTP.  Next I wrote a script that would grab my last weight data submitted from my Garmin Scale on Garmin Connect. Finally, I leveraged Autohotkey to map a shortcut to launching a custom PowerShell script I wrote to bring all of these pieces together.

Putting it all together, the work flow I’ve come up with is as follows:

  1. Each morning I first step on my Garmin Index scale which sends all of my weight and health data to Garmin Connect
  2. I power on my S100 camera and on my computer I press “Windows Key+Z”.  This launches my master PowerShell control script.  I then stand in front of the camera at which point the photo is taken, cropped, the date and my weight is added to the bottom right of the image, it’s converted into an animated gif adding to all of the images from previous days and it’s uploaded to my website, all automagically

I’ve included links below to all of the software used as well as my master PowerShell control script for reference.  This can be useful for other forms of camera automation.  For example, you can use the techniques described below to take pictures from multiple cameras at the same time or create more elaborate time lapse photos or any number of other things.  The limit is really your imagination.

Determine the firmware version installed on the camera now so you know what version of the CHDK custom firmware to download

Download the custom CHDK firmware – I used the full version

Download and install the libusb driver for Windows to allow PTPcam to access the camera directly over USB

The software that includes ptpcam.exe that is used to actually control the camera with LUA commands
ptpcam_V2.0.zip (In German)

ImageMagick includes the command line tool convert.exe allowing for cropping and annotation of images as well as converting from JPG to GIF

Gifscile is a command line tool that can generate an animated gif from an included input of individual gifs

The PowerShell script I cobbled together to make all this work is below.  It’s far from perfect but it does what I needed it to do so.

Leave a Reply

Your email address will not be published.