Motion Detection too slow? - page 5 - Script Writing - CHDK Forum

Motion Detection too slow?

  • 253 Replies
  • 204072 Views
*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Motion Detection too slow?
« Reply #40 on: 02 / February / 2008, 11:55:35 »
Advertisements
i have a small device i can use my old analog slr flash with. it transforms the ttl flash into a slave flash (so the "big flash" is fired off by the built-in small flash). havent tested it yet,but maybe it responds to lightning as well, but not for firing of the flash, but for usb-remote-firing the cam. that should be a lot faster.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Motion Detection too slow?
« Reply #41 on: 02 / February / 2008, 15:15:01 »
I took some photos of the MD_Test2.exe (8s, 20ms, 20ms) on the a570is in M mode, manual focus using Barney's Lightning6 script (default values except increased trigger delay to 40 to be safe and apparently reduced threshold to 7 but I believe that shouldn't affect this test as the flash is bright).

I let the MD run for a while and found that there is significant variation from shot to shot: I got approximate delays of about 120 ms to 260 ms from 9 consecutive shots with histogram and OSD enabled. All "lightnings" were detected, which is good news of course.

I then disabled CHDK OSD and histogram and took 13 more shots, with the same result.

I must note that the test program is not working very well on the computer I tried it on: the bars don't move smoothly at all. This is of course visible in my shots as well (using 1 ms shutter, unnecessarily fast). There are bars being set randomly on or in between the grid lines, anything from 1 to 3 bars being lit partially a time (with 20 ms per bar and 1 ms shutter time, I really should only be getting two partial bars at most), making it a bit hard to determine what really should be written down as the result.

I also took a video using the 60 fps mode of my camera and took a look at it frame by frame in a video editor, and approximated that (if it really is 60 fps) that my range was roughly 120 to 240 ms, close to what I calculated from the stills.



*

Offline mx3

  • ****
  • 372
Re: Motion Detection too slow?
« Reply #42 on: 02 / February / 2008, 15:17:04 »
Q: what minimal motion detection interval can be?
A:
motion detection feature uses LVF (Live View Finder) data - image frames which are displayed on LCD.
they are updated on LCD 30 times per second.
motion detection algorithm compares these frames to decide whether change have been detected.
so minimal detection time must be 1 second / 30 frames = 30 milliseconds

unfortunatelly for analysis used only one of three data buffers which are available

It can be improved a litle (change time from 100 msecs to 30)

Q: what can be done to speed-up motion detection feature?
A: assuming shot is made immediatelly there are two ways to achieve smaller reaction time

1) change function vid_get_viewport_live_fb in a such way it will return right buffer address in time (min interval 30 msecs)

2) change behaviour of "immediate shoot" option (it does not work right now as it was intended ) .
I'm not sure how much time can be saved by this option ( 10 msecs? )





skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

Re: Motion Detection too slow?
« Reply #43 on: 02 / February / 2008, 15:47:54 »
Hi Barney Fife,

here is your script modified to version 7 :):


@title MD Lightning7
@param a Columns
@default a 6
@param b Rows
@default b 4
@param c Threshold (0-255)
@default c 10
@param d Compare Interval (millisecs)
@default d 1
@param e Trigger Delay (0.1 secs)
@default e 12
@param f Rows to Exclude
@default f 0
@param g Pix-Step(speed/accuracy adj)
@default g 8
@param h Reg Mode(0-no,1-incl,2-excl)
@default h 0
@param i Measure Mode(1-Y,0-U,2-V)
@default i 1
if a<1 then a=1
if b<1 then b=1
if c<0 then c=0
if g<1 then g=1
if f<1 then f=1
e=e*100
print ">[";a;",";b;"] threshold: ";c
x=30000
while 1
 press "shoot_half"
 t=0
 md_detect_motion a, b, i, x, d, c, 1, t, h, 1, 1, a, f, 0, g, e
 if t then click "shoot_full"
wend
end


I don't know if this is faster but shorter :D


Re: Motion Detection too slow?
« Reply #44 on: 02 / February / 2008, 16:36:22 »
mx3, I'm still trying to understand the CHDK sources. But it seems the 'immediate shoot' option uses the kbd_sched_shoot function. Looking at that function it seems to wait for the flash etc. Is that the "normal" shoot function? In other words, can this be changed to the "shoot_full" equivalent and that will speed it up? Everyone is now putting half presses in their scripts now so that should be fine?

If anyone is still finding the test program useful, I'm about to rewrite it. Since it could probably be useful in other areas it's probably worth making it better. And I was going to try adding an automated line counter or such, where you import the image and it calculates the timings.

fudgey, what sort of monitor do you have? Could you send me a sample shot which shows the lines not being shown correctly so I can understand the problem?

*

Offline mx3

  • ****
  • 372
Re: Motion Detection too slow?
« Reply #45 on: 02 / February / 2008, 16:48:17 »
mx3, I'm still trying to understand the CHDK sources. But it seems the 'immediate shoot' option uses the kbd_sched_shoot function. Looking at that function it seems to wait for the flash etc. Is that the "normal" shoot function? In other words, can this be changed to the "shoot_full" equivalent and that will speed it up?
immediate shoot option right now uses equivalent of "shot" ( and it is not best variant as you know now)
I have planned this option not knowing about shoot_full ( I have been novice to CHDK myself)
only thing I have thought about this option - to speedup process for 10 msecs



of course implementation is not the best
skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

Re: Motion Detection too slow?
« Reply #46 on: 02 / February / 2008, 17:29:36 »
Deleted
« Last Edit: 22 / April / 2008, 10:21:39 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

Re: Motion Detection too slow?
« Reply #47 on: 02 / February / 2008, 19:08:40 »
Hi Barney Fife,

I think you are right  :)

I have just tested another modification for objects where you have not to focuse every time (for example lightnings) and put the press "shoot_half" outside the loop:

Code: [Select]
...
snip
x=30000
press "shoot_half"
while 1
 t=0
 md_detect_motion a, b, i, x, d, c, 1, t, h, 1, 1, a, f, 0, g, e
 if t then click "shoot_full"
wend
end

The time between the shots is very short now and you get every lightning  :D

Re: Motion Detection too slow?
« Reply #48 on: 02 / February / 2008, 19:14:18 »
Deleted
« Last Edit: 22 / April / 2008, 10:22:08 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

Re: Motion Detection too slow?
« Reply #49 on: 02 / February / 2008, 19:39:52 »
Well I just changed the source code from calling the kbd_sched_shoot to calling kbd_sched_press( KEY_SHOOT_FULL ) but it doesn't take a shot at all. Really having trouble understanding this source code. Guess I'll have to ask at the development forum.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal