26
Jul
08

Paperless geocaching with CHDK

When I go geocaching, I used to bring my PDA for the cache descriptions. I was having gadget overload with a camera, a GPS receiver and a PDA. That is a lot to carry, especially when I go hiking. Now, with CHDK, I don’t need to bring my PDA any more. I just save the cache descriptions as text files, and copy them to my SD card. When I am at the cache site, I use the CHDK text file reader to get the cache description.

This is great for overseas trips. Before, I couldn’t go paperless since I didn’t want to bring my PDA when I travel abroad. I reverted to paper cache descriptions, and had to be quite selective since I didn’t want to bring a thick stack of paper. Now I can have all the cache information in my camera. No need to choose beforehand. Thanks CHDK!

20
Jul
08

Playback filename in CHDK

When I tested the caption reading code, I first hard coded the image location. When that worked, I changed it to use gui_fselect_init() in core/gui_fselect.h to pick the image file. What I really wanted was to show the caption of the image currently displayed.

I looked in include/platform.h, which has get_target_dir_num() and get_target_file_num(). They seem to return the directory and the file numbers for the last photo taken. The implementation uses get_parameter_data(). I turned on the “Debug parameters -> Show Parameter Data”, and paged through to see if any one looked like data for the current file name. Nothing.

I searched on the internet with all kinds of keywords. Finally I found a forum thread on detecting the existence of a RAW file of the currently viewed JPEG file. That code grabs the playback filename from memory, not properties. I immediately went to “Debug parameters -> Memory browser” to see if the same address stores the playback filename for my camera too. Nope. I browsed a bit, then realized that I would never find this manually.

I turned the task over to the trusty computer. Using core/gui_debug.c as an example, I wrote a loop to look for a particular filename in memory. I loaded that program when the name matches the current file, and when it does not. Comparing the two, I found two addresses for storing the playback filename. Strange, I thought. Then I got the brilliant idea of trying a video. Just as I suspected, one address was for the AVI file, the other for the THM file. For photos, the two are the same.

That was the secret ingredient I needed for on-screen caption display. Modifying core/gui_osd.c was relatively easy. I just followed the example for the clock display. Now I can browse my photos, with the caption right there, on the screen. Oh joy!

16
Jul
08

IPTC parser

To store the caption in the image, I decided to use the IPTC metadata headers. As a test, I use IrfanView to add a caption in the IPTC data of an image taken by my camera, and put the SD card back. The camera displayed the image normally. Sanity check passed.

Next I looked for a IPTC library in C. libiptcdata seemed to fit the bill, so I got it and tried to integrate it with CHDK. I tried compiling it separately, moved it into CHDK, and neither worked. It gave me trouble with stdarg.

Frustrated, I did a hex dump of the JPEG file. The data format did not look too complicated. I then found an excellent article describing the layout for the IPTC header. Equipped with that, I wrote my own code to extract the caption field out of the IPTC header. And it worked! Very very exciting.

15
Jul
08

Hello CHDK

Following the great programming tradition, my first CHDK modification is Hello World. I added an entry under “Miscellaneous stuff” called “Hello World”, which prints “Hello!” on the screen. Here is what I did:

  1. Define LANG_MENU_MISC_HELLO is core/gui_lang.h and core/gui.lang.c. Increment GUI_LANG_ITEMS in the header file.
  2. Added the files core/gui_hello.h and core/gui_hello.c. There is only one function:
    void gui_hello_init() {
      draw_clear();
      draw_txt_string(1, 1, "Hello!",
                      MAKE_COLOR(COLOR_WHITE, COLOR_BLACK));
    }
  3. Add GUI_MODE_HELLO to the enum Gui_Mode in include/gui.h.
  4. Modify code/gui.c. Follow calendar as an example.
  5. Add gui_hello.o to OBJS in core/Makefile.

The CHDK directory structure is quite straight-forward: core contains rendering code, and include provide APIs to libraries. I am happy to report that it was quite easy to write Hello World!

14
Jul
08

CHDK in Eclipse

Whenever I come back from vacations, I found it very daunting to organize my photos. Wouldn’t it be great if you can do some of that work while idling in an airport? Yes, you can do that with a laptop, but I want to travel light. Captioning on the camera would be awesome. I searched around for that, and happened upon this great tool called CHDK. CHDK enhances Canon Powershot cameras without firmware modification. Instead, it is loaded from the SD card on boot. Sounds like a great platform for my needs!

Here is how I set up my Windows computer for CHDK development:

  1. Install Eclipse.
  2. Install Subclipse, the Eclipse Subversion plugin.
  3. Checkout the CHDK code base.
    In Eclipse, switch to the “SVN Repository Exploring” perspective. Right click to get a New Repository Location, and point it to https://tools.assembla.com/svn/chdk/trunk.
  4. Download gcc for CHDK. Follow instructions on the CHDK wiki.
  5. Change build parameters in Eclipse.
    Switch to the “C/C++” perspective. Go to “Project -> Properties -> C/C++ Build”. Under the tab “Build Settings”, change the build command to “gmake” (or the full path if you have not set up the environment variable). Under the “Behaviour” tab, change the build target to “fir PLATFORM=ixus860_sd870 PLATFORMSUB=100c“. The values for PLATFORM and PLATFORMSUB depends on your camera make and its firmware version. Refer to the CHDK FAQ for steps to get the firmware version of your camera.
  6. Add the CHDK includes in Eclipse.
    Go to “Project -> Properties -> C/C++ General -> Paths and Symbols”. Under the tab “Includes”, click on “GNU C”, and add the “include” directory as a workspace include.
  7. Press Ctrl-B to build.



April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930  

Archives

free counter statistics