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

Motion Detection too slow?

  • 253 Replies
  • 187549 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Motion Detection too slow?
« Reply #150 on: 10 / February / 2008, 13:57:14 »
Advertisements
I took mx3's immediate shoot patch from http://chdk.setepontos.com/index.php/topic,405.msg3580.html#msg3580 (without the triple buffer modification)
and removed the shutter release command and the wait from it because I want my MD script to be able to use continuous shooting mode / preview (i.e I let my script release the shutter that is pressed by md_detect_motion).

I applied the modifications to current trunk (297) and tested the speed using my LED blinker and script (obviously I removed the shutter_press/click commands and only used shutter_release commands). Using the a570is here as usual.

I got reaction times between 81+-3 ms and 150+-5 ms, averaging at 110 ms. A bit worryingly I also got one shot that exceeded the measurable delay of 195 ms (this is out of 61 shots in two sets). That one shot aside, this is a steady 30 ms improvement to the old unmodified non-immediate MD shoot mode code using allbest #16 I tested earlier in this thread.

For your reference, the shooting function (placed in core/kbd.c) i used in place of kbd_sched_shoot() in motion_detector.c:

Code: [Select]
void md_kbd_sched_immediate_shoot(){
  kbd_int_stack_ptr-=1;// REMOVE MD ITEM
  KBD_STACK_PUSH(SCRIPT_MOTION_DETECTOR); // it will removed right after exit f$
  // not a stack operation... pressing right now
  kbd_key_press(KEY_SHOOT_FULL);
}

I was under the impression that the normal (non-immediate mode) code was the current state-of-the-art, but I couldn't find a patch for that in this thread. GrAnd commented to core/kbc.c : kbd_sched_shoot() earlier so I tried to modify it by commenting out the one line that was supposedly generating 50 to 60 ms delay for no profit:
Code: [Select]
//    KBD_STACK_PUSH(SCRIPT_WAIT_EXPHIST);but this had no effect what so ever, results were as before (110--180 ms response time).

Exactly what have you people been modifying for those speedy s3 and a610 builds?

Re: Motion Detection too slow?
« Reply #151 on: 10 / February / 2008, 15:17:46 »
Deleted
« Last Edit: 22 / April / 2008, 10:33: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 #152 on: 10 / February / 2008, 17:03:02 »
fudgey,
in s3 I used the mod from
http://chdk.setepontos.com/index.php/topic,405.msg3580.html#msg3580
but NOT the the viewport part (it seem to slow this down on the s3), only the kbd mods.

Re: Motion Detection too slow?
« Reply #153 on: 10 / February / 2008, 17:08:42 »
Oh, sorry I see you already did that. (It's been some late nights :blink:)


Re: Motion Detection too slow?
« Reply #154 on: 10 / February / 2008, 17:31:08 »
Deleted
« Last Edit: 22 / April / 2008, 10:34:03 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

*

Offline mx3

  • ****
  • 372
Re: Motion Detection too slow?
« Reply #155 on: 10 / February / 2008, 21:53:24 »
I think I've just figured out where some of those spurious shoots are coming from.

I was curious how many cells I could define with the Rows Cols options. With 30 columns and 20 Rows it would trigger the shutter, so I figured I should increase the timeout like I had in the past to prevent that. I had the lens-cap on to test this, I wanted to count how many rows and columns were the top limit. So, no light was getting in. Then I noticed what was triggering it. A bunch of little red squares were lighting up in random spots on my screen. Ahah! I had the sensitivity set to the default 10. It was triggering off of noise! So, increase the triggering sensitivity a bit to avoid those. 10 is right on the threshold of sensor noise.

I wonder who will be first to add auto threshold adaptation code?

supose user selects 0 as threshold - it is no good as you know
script decide itself what threshold to use
it begins loop from 1 to 255 to select threshold
using combination of t (count of detected cells) and getcurrenttime (I don't remember exactly name) it is possible to get rid of bad threshold values (which cause constant shooting)
skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

*

Offline mx3

  • ****
  • 372
Re: Motion Detection too slow?
« Reply #156 on: 10 / February / 2008, 22:06:26 »
some more old idea about adaptation
Canon Talk Forum: Digital Photography Review

Quote
- extended regions - store regions definition in file

contect of the file would be like that for 3x3 split:
>>>
10, 255, 10
25, 10, 0
15,45,70
<<<
255 - means "ignore this cell".
0 - any color change in this cell will trigger MD.


so it will be possible to :
 1) launch camera script for some time to adjust to scene
 2) authomaticaly save "grid"(detector definition) file
 3) try to detect movement using saved file


imagine big city with cars moving and you are trying to capture helicopters :-)
so what is the problem?
you setup your cam. it works for some time and collects statistics.
cars movement regions are detected.
file for currecnt scene is saved.
next use of MD can use generated file to exclude some unwanted regions...
skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

Re: Motion Detection too slow?
« Reply #157 on: 11 / February / 2008, 03:32:51 »
Deleted
« Last Edit: 22 / April / 2008, 10:34:26 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


*

Offline mx3

  • ****
  • 372
Re: Motion Detection too slow?
« Reply #158 on: 11 / February / 2008, 03:35:36 »
Interesting idea. I'm wondering how it would work in real-world use though. Or if things just change too much where an automatic mask and threshold would become outdated too rapidly to make this as useful as it sounds. In your traffic vs. helicopter scenario, for example. what if clouds move in or as the sun moves across the sky. It would have to call up a recalibration every so often.

sun and clouds will not trigger detection bacause theirs move slow
any way it is just idea :-)

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

Re: Motion Detection too slow?
« Reply #159 on: 11 / February / 2008, 04:14:27 »
I wonder who will be first to add auto threshold adaptation code?

supose user selects 0 as threshold - it is no good as you know
script decide itself what threshold to use
it begins loop from 1 to 255 to select threshold
using combination of t (count of detected cells) and getcurrenttime (I don't remember exactly name) it is possible to get rid of bad threshold values (which cause constant shooting)


You can use the AdaptiveMD script, on the wiki. Note that the threshold to avoid triggering by noise
is light level dependent, due to the amplification changes in the viewport, I suppose.
Using  the number of shots in a specified time frame does assume something about your scene's,
and is therefore not generally applicable (tried that one first). Besides that you need to set
a time interval in which you consider `too few' shots, to decrease the threshold, otherwise
the threshold may stay too high.

 

Related Topics