Downloading a picture that was just taken with chdkptp - General Help and Assistance on using CHDK stable releases - CHDK Forum

Downloading a picture that was just taken with chdkptp

  • 4 Replies
  • 7211 Views
Downloading a picture that was just taken with chdkptp
« on: 21 / September / 2011, 13:50:43 »
Advertisements
Is there a way using chdkptp and lua code to download the last picture you just took?

For example, say I take a picture like so:

Code: [Select]
./chdkptp -ec -e"luar shoot()"
How could I then download the picture that was just taken without necessarily knowing it's filename (ie listing the files and finding it). I would think that shoot() should return something along the lines of an identifier to let you know where the image that was just captured was stored or something. Is there any way to get that information?

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Downloading a picture that was just taken with chdkptp
« Reply #1 on: 21 / September / 2011, 15:01:28 »
See http://chdk.setepontos.com/index.php?topic=4338.msg56162#msg56162 for an example that does list images but is easy to use (unless you run out of memory on the camera). Please note that the PTP stuff in that post may be horribly outdated, but the Lua part using disk.lua and timelapse_example.sh should help you for getting the most recent photo.

*

Online reyalp

  • ******
  • 14080
Re: Downloading a picture that was just taken with chdkptp
« Reply #2 on: 22 / September / 2011, 00:17:41 »
You might be able to work out the name of the last shot image from get_exp_count()

Or you could simply delete each image after you download it, and then you could just list all the images and download whatever is there.

In chdkptp, you can easily write PC side scripts that interact with data returned by lua. See downloaddir() in lua/chdku.lua for an example of listing and downloading files.

I would suggest that you build lua scripts do do what you want, rather than trying to execute single commands one at a time.
Don't forget what the H stands for.

Re: Downloading a picture that was just taken with chdkptp
« Reply #3 on: 22 / September / 2011, 17:30:43 »
I am a little bit confused at how exactly to write a PC-side script with chdkptp.

Let me explain my situation a little bit. I'm working with a system that will be controlling multiple cameras over USB, not all of which are CHDK cameras. The system software that controls all these different cameras is written in Python. We have a Python class for each camera we will be using (thermal, infrared, near-infrared, RGB, etc). We need a Python class for a CHDK camera. So what I need to do is implement a couple functions in Python that will do the following:

Set to record mode (done)

Set to playback mode (done)

Capture an image (done)

Download the last image captured

So far the first three are just system calls using chdkptp or ptpcam. The tricky part is the last one, downloading the last image captured. If I had a way to get the name of the captured image in the Python software, that would be best. However, I'm also thinking that I could do something like the following:

Capture an image
Download all images (simple with ptpcam)
Delete all images (also simple with ptpcam)

I need the name of the image that was downloaded in the Python software as well. I can easily pipe the output of the download to find the filename and pass it back to Python, though it's a bit hacky (piping it to a file, pattern matching that file, etc).

You say you would suggest lua scripts to do what I need rather than executing single commands one at a time. In this context, would that really work? The Python software is the controller, I just need to write the wrapper functions that will get the above commands to work properly.

Also, we are concerned with how rapidly we can take pictures continuously. One of the biggest bottlenecks in this area is writing the picture to the camera's SD card. Is there a way that you know of to have CHDK capture an image, but skip writing it to the SD card and then just download it from RAM (to the PC)? A colleague of mine did this with Canon's T1I DSLR cameras using gphoto.


*

Online reyalp

  • ******
  • 14080
Re: Downloading a picture that was just taken with chdkptp
« Reply #4 on: 23 / September / 2011, 00:56:27 »
I am a little bit confused at how exactly to write a PC-side script with chdkptp.
Look in the lua directory.

Quote
Download the last image captured
As I've explained, there is no simple 'get the last captured image name' function. You might be able to figure it out from the image counter. Or just stat them all and download the most recent. Or write a function that stats them on the camera and returns the name of the most recent.
Quote
You say you would suggest lua scripts to do what I need rather than executing single commands one at a time. In this context, would that really work?
What I mean is if you want to do something complicated like listing the files and figuring out the most recent one and printing the name in some particular format, you can easily write a new CLI command (or add a function that you can execute with !) to do all that in one go. The entire chdkptp CLI is written in lua. Admittedly, it's unfinished and a bit of a mess, but if you are writing a python system to control a bunch of cameras, you really shouldn't have much trouble extending it to meet your needs.
Quote
Also, we are concerned with how rapidly we can take pictures continuously. One of the biggest bottlenecks in this area is writing the picture to the camera's SD card. Is there a way that you know of to have CHDK capture an image, but skip writing it to the SD card and then just download it from RAM (to the PC)?
This is not currently possible using the CHDP PTP extension.
Don't forget what the H stands for.

 

Related Topics