Need advice on how to use CHDKPTP to retrieve file name of last picture taken - General Discussion and Assistance - CHDK Forum

Need advice on how to use CHDKPTP to retrieve file name of last picture taken

  • 1 Replies
  • 4875 Views
Advertisements
I'd like to use an AVR2560 or ARM Cortex-M4F microcontroller to somehow trigger a Canon to take a picture and then I'd like to retrieve that pictures filename (not the file itself, just an identifier of the picture) back into the microcontroller so that it can be stored in a log file.  The microcontroller is actually a multicopter flight controller so it knows it's attitude, gps location, etc but I want to make sure that after the flight, when the user downloads the dataflash files from the microcontroller and the images from the camera that they can easily be tied together.  So this is why I would like the microcontroller to get the file location so it can store it along with the position data.

I had a look through the scripting cross reference page http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page but I didn't see an obvious way using chdkptp to get the filename of the image just taken.

Any suggestions?

P.S. I'm fairly experienced with embedded programming but not at all experienced with CHDK yet.
The flight controllers I'm talking about are the APM2.6 or PX4 running "ArduCopter".

*

Offline reyalp

  • ******
  • 14121
The CHDK PTP interface mostly works by sending Lua code to the camera to run.

Using Lua, you can get the last file name using something like
Code: [Select]
imgname=string.format('%s/IMG_%04d.JPG',get_image_dir(),get_exp_count())
Note in some situations, it might be sufficient to just store the number, or the number and time to disambiguate if it wraps around.

To get this from a microcontroller, you will need a USB stack, and a PTP client library, and implement enough of the CHDK PTP protocol to execute scripts and read the messages containing the script return value.

Information about the PTP protocol can be found at http://chdk.wikia.com/wiki/PTP_Extension

Some people have successfully implemented PTP support on Arduino, see

http://chdk.setepontos.com/index.php?topic=6969.msg84799#msg84799
http://chdk.setepontos.com/index.php?topic=6041.msg60665#msg60665

An alternate approach would be to trigger the shots using GPIO from your microcontroller with USB remote function http://chdk.wikia.com/wiki/USB_Remote and log enough information on the camera to correlate the images and flight controller data later.

A note on terminology.
"CHDK PTP" refers to the PTP extension in CHDK.

"chdkptp" generally refers to the PTP client I wrote: https://www.assembla.com/spaces/chdkptp/wiki
This can be built for normal linux distros and windows, but would probably be difficult to port to a microcontroller environment. It might be a useful example if you end up writing your own client.
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal