Script works slower than manual shooting - Script Writing - CHDK Forum supplierdeeply

Script works slower than manual shooting

  • 11 Replies
  • 2567 Views
Script works slower than manual shooting
« on: 14 / October / 2012, 09:19:31 »
Advertisements
Hello,

I'm working on a time lapse script. Basically, I want it to first focus, then take a number of shots every second, release focus, and repeat. I want to do the focus thing every few shots, to make sure focus/shutter speed/white balance/... is corrected every time, and it doesn't drift or gets too dark when it gets dark outside.
Only difference to a normal time lapse is that I want to control the shots externally.

Sometimes the interval will change, and this depends on gps and other data. So it's not something that I can include in the script. Thus it needs external control.

Right now, I wrote a script that checks the pulse duration on the USB port, and acts accordingly.

But for some reason I can't make the camera to shoot quick enough to get 1fps. If I do it manually (holding half way, and clicking away at 1fps), the camera does it without a problem. But in script, it seems like it take longer.

Are there some things i have to enable or disable to make it work faster? I already tried changing the yield settings. But this didn't really help. It did however change the output of the USB pulse function.

This is what I have right now. It still needs other functions and fail safes, but I want to get it working first.

Code: [Select]
@title Time Lapse Controller

print_screen 100*(get_time 2) + get_time 1

print "Perform setup"

set_quality 1
print "Quality 1"

set_resolution 1
print "Resolution 1"

if get_capture_mode = 0 then
  print "Switch to record mode"
  set_record 1

    while get_capture_mode = 0
    sleep 100
    wend

  print "Record mode"
endif

set_yield 10 1
sleep 20
print "Script speed-up"

print "Script started"

a=0

while 1

while a=0
a = get_usb_power 0 until
wend

print a

rem 1 to 3: 10 to 50ms
rem 5 to 7: 80 to 120ms
rem 9 to 11: 170 to 210ms
rem 13 to 15: 250 to 290ms

select a
  case 1 to 3; gosub "focus_hold_shoot"
  case 13 to 15; gosub "focus_hold"
  case 5 to 7; gosub "quick_shoot"
  case 9 to 11; gosub "quick_shoot_release"
end_select

a=0

wend

:focus_hold_shoot
print "focus_hold_shoot"
press "shoot_half"
sleep 50
click "shoot_full_only"
return


:focus_hold
print "focus_hold"
press "shoot_half"
return


:quick_shoot
print "quick_shoot"
click "shoot_full_only"
return


:quick_shoot_release
print "quick_shoot_release"
click "shoot_full_only"
release "shoot_half"
return

Any help would be appreciated!
Thanks!

Re: Script works slower than manual shooting
« Reply #1 on: 14 / October / 2012, 11:11:46 »
But for some reason I can't make the camera to shoot quick enough to get 1fps. If I do it manually (holding half way, and clicking away at 1fps), the camera does it without a problem. But in script, it seems like it take longer.
There have been a few discussions about this. Getting down to 1 fps is hard with scripts - the consensus of the discussions was that Canon does something "special" when you do it manually.  I believe it comes down to how fast you can transfer images to the SD card.  Canon buffers the images in RAM when fast shooting so that the shutter does not have to wait for the image to store before taking another.  CHDK can't do this unfortunately and nobody has really looked at how to get CHDK to trick the camera into do it.   This came out in another thread where I did a "special" build of CHDK with almost everything stripped out to get more RAM for photo buffers during manual fast shooting.


Quote
Are there some things i have to enable or disable to make it work faster?
You seem to have found the usual tricks - holding half-press down,  focus lock and shoot_full_only.

You might find that a Class 10 SD card helps if you are not using one.  Beware of counterfeits  - use the CHDK debug menu write speed tests if not sure of a particular card.

Quote
I already tried changing the yield settings. But this didn't really help. It did however change the output of the USB pulse function.
That's a bug (unless it was just improving the resolution of the pulse?).  I'll look at how complicated the fix would be and maybe just document that you need to expect different pulse width values (and possibly pulse count parameters) if you fool with the yield settings.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script works slower than manual shooting
« Reply #2 on: 14 / October / 2012, 11:16:15 »
Damn! So solving this might be opening the camera and wiring up the button....

If you look at my remark lines, you see how long I had to make the pulses to get the correct USB outputs.

Re: Script works slower than manual shooting
« Reply #3 on: 14 / October / 2012, 11:44:11 »
Damn! So solving this might be opening the camera and wiring up the button....
Maybe somebody else will post a better solution.   I've played with this a bit but not exhaustively.  CHDK simulates pressing the cameras buttons so I'm not sure why it won't shoot faster ?

I think something like this is as fast as you can go with a script. But maybe the problem is waiting for get_shooting() to be true ?   That might be causing the script to wait until the image has been written to the SD card ? It might be possible to blindly pulse the shoot_full_only earlier after a short delay and it would take the next photo (buffered).   You could try that - it would be timing dependent though.

Code: [Select]
--[[
@title Fast Shooter
@param n Number of Shots
@default n 5
--]]

function fastshoot(a1,s1,t1)
   set_av96(a1)
   set_sv96(s1)
   set_tv96_direct(t1)
   press("shoot_full_only")
   repeat
      sleep(10)
   until get_shooting() == true
   release("shoot_full_only")
   repeat
      sleep(10)
   until get_shooting() == false
end

press("shoot_half")
repeat
    sleep(50)
until get_shooting() == true
release("shoot_half")
repeat
    sleep(50)
until get_shooting() == false
set_aflock(1)
av=get_av96()
sv=get_sv96()
tv=get_tv96()

for i=1, n, 1 do
    print("step=", i )
    fastshoot(av,sv,tv96)
end

set_aflock(0)
print("...done")
 
Quote
If you look at my remark lines, you see how long I had to make the pulses to get the correct USB outputs.
Thanks - looks like your yield setting is basically doubling the pulse measurement rate.  I'll update the wiki page rather than change the code at this point.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Script works slower than manual shooting
« Reply #4 on: 14 / October / 2012, 12:33:18 »
Okay - I tried this on my G10.   Looking for 1fps,  I only got 7 of the 10 shots I expected.  Works fine at 2 fps.

Code: [Select]
--[[
@title Fast Shooter
@param n Number of Shots
@default n 10
@param s msec delay
@default s 1000
--]]
set_console_layout(10, 0, 40, 14)
print("Started...")
sleep(1000)
press("shoot_half")
repeat
    sleep(50)
until get_shooting() == true
set_aflock(1)
for i=1, n, 1 do
    click("shoot_full_only")
    sleep(s)
end
release("shoot_half")
set_aflock(0)
print("...done")
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Script works slower than manual shooting
« Reply #5 on: 14 / October / 2012, 13:57:41 »
Oh, guys, I solved this some time ago with this kind of script:

Code: (lua) [Select]
press("shoot_half")
sleep(3000)
--above to get all the things like focus and so on
repeat
    press("shoot_full")
    sleep(10)  --to avoid camera being unresponsive
until 1==2

This is the fastest timelapse possible. Actually - this is the software way to wire the button;)
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

*

Offline msl

  • *****
  • 1269
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Script works slower than manual shooting
« Reply #6 on: 14 / October / 2012, 14:13:35 »
This is the fastest timelapse possible. Actually - this is the software way to wire the button;)
The fastest method is a shooting in continuous mode. ;)

Code: (lua) [Select]
-- switch into continuous mode
press("shoot_full")
-- time or pic count loop
release("shoot_full")

Permanent 1 fps in single shoot mode is an illusion for a Canon cam. Look in the technical descriptions of the cameras.

msl
CHDK-DE:  CHDK-DE links

Re: Script works slower than manual shooting
« Reply #7 on: 14 / October / 2012, 14:18:15 »
Oh, guys, I solved this some time ago with this kind of script:
...
This is the fastest timelapse possible. Actually - this is the software way to wire the button;)
On my G10 (flash off,  review off) this takes one picture and hangs.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Script works slower than manual shooting
« Reply #8 on: 14 / October / 2012, 15:15:01 »
That's not good:) On my sx130 it works perfectly for hundreds photos...

And according to msl - I forgot to say that cam must be in continous shooting mode (like for usual shotting with shutter button pressed).

Maybe you'd need to increase the delay in pause() ?
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: Script works slower than manual shooting
« Reply #9 on: 14 / October / 2012, 15:46:15 »
And according to msl - I forgot to say that cam must be in continous shooting mode (like for usual shotting with shutter button pressed).
Right - setting up continuous shoot mode in the camera is an important step.  Too bad you can't put it into continuous drive mode by setting a property case value.
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics