Is there a way to delete a photo via a chdk script? - Script Writing - CHDK Forum supplierdeeply

Is there a way to delete a photo via a chdk script?

  • 12 Replies
  • 6969 Views
*

Offline cixa

  • *
  • 13
Is there a way to delete a photo via a chdk script?
« on: 04 / July / 2010, 23:00:33 »
Advertisements
Hi,

I'd like to write a script that displays an image and then deletes it. Is this possible?

*

Offline reyalp

  • ******
  • 14079
Re: Is there a way to delete a photo via a chdk script?
« Reply #1 on: 05 / July / 2010, 00:33:55 »
You can delete files from lua: http://chdk.wikia.com/wiki/LUA#Lua_standard_libraries:_io.2C_os.2C_string.2C_and_math

You can't directly display an image from script.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Is there a way to delete a photo via a chdk script?
« Reply #2 on: 05 / July / 2010, 15:11:57 »
And there's always the obvious way i.e. navigating play mode with emulated button presses and deleting with emulated button presses (which is also the only currently available way of deletion that fully makes the camera firmware aware that you've deleted the file).

*

Offline cixa

  • *
  • 13
Re: Is there a way to delete a photo via a chdk script?
« Reply #3 on: 07 / July / 2010, 10:45:21 »
fudgey: can you please elaborate? i wish for a person to take a photo, be displayed for a few seconds, and be deleted immediately.

by 'be displayed' i mean the image that shows up immediately after a photo is taken, not in 'play' mode.


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Is there a way to delete a photo via a chdk script?
« Reply #4 on: 07 / July / 2010, 13:25:38 »
fudgey: can you please elaborate? i wish for a person to take a photo, be displayed for a few seconds, and be deleted immediately.

by 'be displayed' i mean the image that shows up immediately after a photo is taken, not in 'play' mode.


Actually CHDK can change between REC and PLAY with script commands at will. But if what you said above is all you need, you don't need to switch modes because you can Canon's built-in "erase durings shutter hold review" feature (if your camera has that -- consult the manual).

In case this feature is not known to you, this is how it works: Fully press shutter to take a photo. Don't release the shutter. The camera takes a photo, writes it to the SD card and shows the photo on the screen for as long as you keep the shutter pressed down.

While still fully pressing the shutter, press the erase (trashcan) button. The camera will ask for delete confirmation. Press whatever keys it takes to select 'yes' and the file will be gone and you'll be back in live view REC mode.

You can write a script to emulate these keypresses, it will be roughly something like this (in pseudocode, from my vague memories of this feature without testing on a camera):

press shoot_half
wait for focus etc if you wish, in a shoot state loop if you wish, set overrides if you wish
press shoot_full
sleep seconds*1000
press erase
sleep 100
release shoot_full
sleep 20
release shoot_half
sleep 100
press left
press set

*

Offline cixa

  • *
  • 13
Re: Is there a way to delete a photo via a chdk script?
« Reply #5 on: 13 / July / 2010, 14:15:43 »
Here is what I've written so far for the G11:

@title Languria
@param a
@default a 1

press shoot_full
sleep a*1000
press erase
sleep 100
release shoot_full
sleep 20
sleep 100
press right
press set

Doesn't work. Camera hangs and must be rebooted. What could it be?

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Is there a way to delete a photo via a chdk script?
« Reply #6 on: 13 / July / 2010, 15:33:58 »
Maybe your camera doesn't like you pressing shoot_full without first pressing shoot_half (and possibly waiting a tiny little while in between).


*

Offline cixa

  • *
  • 13
Re: Is there a way to delete a photo via a chdk script?
« Reply #7 on: 14 / September / 2010, 13:44:05 »
now i have this:

@title Languria
@param a
@default a 1

press shoot_half
sleep a*1000
press shoot_full
sleep a*1000
press erase
sleep 100
release shoot_full
sleep 20
sleep 100
press right
press set

// and nothing happens> the script is stuck, the camera turns itself off, and i have to restart with the lens still not retracted.

I have a G11. Any ideas, fudgey?


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Is there a way to delete a photo via a chdk script?
« Reply #8 on: 14 / September / 2010, 14:35:11 »
I really don't remember ubasic syntax, but does

press shoot_half

work or should it be

press "shoot_half"

instead (and other keys quoted similarly of course)?

*

Offline cixa

  • *
  • 13
Re: Is there a way to delete a photo via a chdk script?
« Reply #9 on: 15 / September / 2010, 12:13:55 »
yes indeed, the script works halfway now.

it does indeed take a photo, but fails to erase the photo.

the script i have now is:


@title Languria
@param a
@default a 1

press "shoot_half"
sleep a*1000
press "shoot_full"
sleep a*1000
click "erase"
sleep 100
release "shoot_full"
sleep 20
sleep 100
press "right"
press "set"

however, this does not erase the image. can yuo tell me why?

thank you,

cixa

 

Related Topics