Motion Detection too slow?

  • 242 Replies
  • 99913 Views
  • Publish
    Motion Detection too slow?
    « on: 28 / January / 2008, 17:25:11 »
    Advertisements
    Not sure where to ask this so I'll try here.

    After reading about using the md_detect_motion function for capturing lightning, I can't get it to run fast enough on my A610. I have tried both Fingalo and Allbest builds, and the few example scripts on the wiki. With the camera in manual mode, manual focus and noise reduction turned off I can wave my hand slowly in front of the camera (maybe half a second from left to right or so) and it never captures the hand in the shot. Why is this? Is the A610 not fast enough? Or what am I doing wrong? I have tried different cell sizes, different pixel steps and everything and I just can't see it being fast enough for capturing lightning. Can someone tell me what is going on?

    Also, what is the reason that having the "shot delay" parameter too small makes the camera shoot continuously rather than waiting to detect motion? Is it a timing thing?

    I've had a quick look at the source code, and if I can get this working properly as it should (ie, fast enough), I think there are some optimizations I can do specifically for lightning and similar "detection" applications. Maybe even water drops and stuff.

    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Motion Detection too slow?
    « Reply #1 on: 28 / January / 2008, 18:17:07 »
    Of course, you need to disable metering and auto focus to shoot fast and you tried that already. But did you actually get rid of auto focus? I didn't.

    I tried  MLuna's Motion Detection script on allbest build 16 on a570is, and with the "Shot" mode 0=nf, the camera still flashes the focus light and makes the noises it does when it focuses then shoots.

    For what I understand, the script uses the "shoot_full" command to shoot when no focus is desired, but it still seems to take the time to focus before shooting.

    I can get a shot of a hand moving slowly, though (start script, wait for a while, then move the hand slowly enough for the camera to focus and shoot and then wait for long enough for the delays to end before another sweep with the hand). I also used fixed white balance (a setting other than "auto").

    Maybe you should try the test mode "Shot=3" to find out if your lag is related to shooting like mine or the actual motion detection (in test mode the script outputs stuff to the console when it detects movement, and for me it's pretty instant).

  • Publish
    Re: Motion Detection too slow?
    « Reply #2 on: 28 / January / 2008, 18:50:01 »
    Yeah I forgot to mention I tried the test and it doesn't lag at all. And that's right the focus light does flash although I'm using "shoot_full".

    This isn't sounding good. Thought I finally had a useful job for my semi-retired A610. Expecting some good thunderstorms the next few weeks too.

  • Publish
    Re: Motion Detection too slow?
    « Reply #3 on: 28 / January / 2008, 23:20:03 »
    Can somebody give me some help with this please?

    Has anyone used the motion detection on an A610? Is there a way to write a script that stops the camera continuously shooting whether there is motion or not, without having to set the trigger delay too high? And why does it take so long to take a shot? In test mode it is fast. And with the camera on manual everything (without running a script) it is fast. But running a motion detection script just does not seem to work properly.


  • Publish
    Re: Motion Detection too slow?
    « Reply #4 on: 29 / January / 2008, 21:09:57 »
    I've only been using CHDK for about three days now. Still getting a feel for it, but I'm having the same exact situation. Canon G7 Manual mode, manual focus, flash off, and many different script settings. It reacts instantly if the card is full, or in test mode, but it still seems like it wants to focus first.

  • Publish
    Re: Motion Detection too slow?
    « Reply #5 on: 30 / January / 2008, 01:00:36 »
    This is really frustrating me. I'm currently looking through the source code trying to see why this happens. If I take any of the scripts and comment out the "md_detect_motion" line the camera captures shots quickly as it should. It seems the motion detection code is doing something wrong but I can't put a finger on it. And yet all it does is read the live preview and bases the detection algorithm on that, ie it doesn't seem to interfere with anything else.

    The point is, for what ever reason, this function seems to cause my A610 to do focusing and everything else as if it was on "auto" mode, when I actually have it on manual with manual focus at the time of running the script. It just doesn't make sense. I tried putting a second "dummy" call to this function after the proper one in case it was to do with buffers not being cleared or something but it didn't help. I really hope either mx3, fingalo or someone will give some input on this.

    Basically, the way this function is at the moment on my camera, it's useless.

    *

    Offline mx3

    • ****
    • 372
  • Publish
    Re: Motion Detection too slow?
    « Reply #6 on: 30 / January / 2008, 04:00:44 »
    see sample images - I'm throwing toys of my son
    md_test_images_1.rar - 7.35MB
    is it fast enough for you?

    a630
    manual mode
    manual focus
    noise reduction is Off
    shoot_full
    skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

    *

    Offline mx3

    • ****
    • 372
  • Publish
    Re: Motion Detection too slow?
    « Reply #7 on: 30 / January / 2008, 04:09:24 »

    Also, what is the reason that having the "shot delay" parameter too small makes the camera shoot continuously rather than waiting to detect motion? Is it a timing thing?


    md uses LCD data.

    after shoot LCD goes blank and after that shows live picture again
    maybe MD algorithm uses blank snapshot as a base for comparison
    or some other factor - may be camera adjusts image's average luminosity while restoring Live picture (and it takes some time?)
    skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler


  • Publish
    Re: Motion Detection too slow?
    « Reply #8 on: 30 / January / 2008, 05:22:52 »
    Ok mx3. I want it to work like your toy throwing :) Can you post your script please?

    On my A610, the first shot after motion occurs is taken properly. But after that the camera just keeps on taking photos without waiting for motion. The person who posted the general purpose motion detection script said that on their camera, this occurs if they don't use a delay amount of at least 5 seconds, but they don't know why that is. I would like to know. The whole idea of using this to capture lightning is having the shutter open at the correct times, increasing the chance to almost 100% that every shot will have lightning in it. But if I have to set the delay to more than 5 seconds and have a shutter speed of 1 second, well I'll have like a 17% chance of capturing a strike. But it is too slow anyway. An intervalometer would do a better job.

    Your sample shots of throwing the toys? I need to know how you do it. Because that's how I expected it to work. But it doesn't on my A610 with everything I've tried. Like I said before I can slowly wave my hand in front of the camera and by the time the shot is taken the hand has passed. What is your script and what are the camera settings used for the toy throwing examples?
    « Last Edit: 30 / January / 2008, 05:35:59 by jonnythe »

    *

    Offline mx3

    • ****
    • 372
  • Publish
    Re: Motion Detection too slow?
    « Reply #9 on: 30 / January / 2008, 05:46:10 »
    Ok mx3. I want it to work like your toy throwing :) Can you post your script please?
    Code: [Select]
    @title md split h3

    @param a Columns
    @default a 8

    @param b Rows
    @default b 6

    @param c Threshold (0-255)
    @default c 10

    @param d compare Interval (millisecs)
    @default d 80

    @param e Begin Triggering Delay(secs)
    @default e 20

    @param f Rows
    @default f 1

    @param g pix step(speed/accuracy adj)
    @default g 8

    @param h  reg mode(0-no,1-incl,2-excl)
    @default h 2

    @param i measure mode(1-Y,0-U,2-V)
    @default i 1


    if a<1 then let a=1
    if b<1 then let b=1
    if c<0 then let c=0
    if g<1 then let g=1
    if f<1 then let f=1

    let e=e*1000



    print ">[";a;",";b;"] threshold: ";c

    let x=30000

    for z=0 to 10000

    let t=0

    rem              /--/-columns, rows to split picture into
    rem              |  |
    rem              |  |  measure mode (Y,U,V R,G,B) - U-0, Y-1, V-2, 3-R, 4-G, 5-B
    rem              |  |  |                     
    rem              |  |  |  timeout
    rem              |  |  |  |  comparison interval (msec)
    rem              |  |  |  |  |  threshold ( difference in cell to trigger detection)
    rem              |  |  |  |  |  |  draw_grid (0-no, 1-yes)
    rem              |  |  |  |  |  |  |  return variable. number of cells with motion detected
    rem              |  |  |  |  |  |  |  |
    rem              |  |  |  |  |  |  |  |  VVVVVV  OPTIONAL PARAMETERS: VVVV
    rem              |  |  |  |  |  |  |  |
    rem              |  |  |  |  |  |  |  |  region (masking) mode: 0-no regions, 1-include,  2-exclude
    rem              |  |  |  |  |  |  |  |  |  region first column
    rem              |  |  |  |  |  |  |  |  |  |  region first row
    rem              |  |  |  |  |  |  |  |  |  |  |   region last column
    rem              |  |  |  |  |  |  |  |  |  |  |   |    region last row
    rem              |  |  |  |  |  |  |  |  |  |  |   |    |   parameters- 1-make immediate shoot, 2-log debug information into file. OR-ed values are accepted
    rem              |  |  |  |  |  |  |  |  |  |  |   |    |   |  pixels step - speed vs. Accuracy adjustments (1-use every pixel, 2-use every second pixel, etc)
    rem              |  |  |  |  |  |  |  |  |  |  |   |    |   |  |  number of milliseconds to wait before begin triggering - can be useful for calibration with "draw_grid" option
    rem              |  |  |  |  |  |  |  |  |  |  |   |    |   |  |  |
    rem              V  V  V  V  V  V  V  V  V  V  V   V    V   V  V  V
    md_detect_motion a, b, i, x, d, c, 1, t, h, 1, 1,  a,   f , 0, g, e

    if t<1 then goto "zzz"

    click "shoot_full"
    rem sleep 10
    rem release "shoot_full"

    :zzz

    next z


    end

    I used 8x6 grid
    15 msec - comparison interval ( really change occurs every 100 msec. but this can be tweaked to 30 msec. see bellow)
    I used delay - 1sec
    30 sec - timeout (can be freely increased to hours. only purpose of it to allow execution of other basic commands )
    I used allbest's 16 unmodified build


    On my A610, the first shot after motion occurs is taken properly. But after that the camera just keeps on taking photos without waiting for motion. The person who posted the general purpose motion detection script said that on their camera, this occurs if they don't use a delay amount of at least 5 seconds, but they don't know why that is. I would like to know.
    I'm not sure. maybe they use preview of taken picture or something else
    what delay value sutisfied you?

    The whole idea of using this to capture lightning is having the shutter open at the correct times, increasing the chance to almost 100% that every shot will have lightning in it. But if I have to set the delay to more than 5 seconds and have a shutter speed of 1 second, well I'll have like a 17% chance of capturing a strike. An intervalometer would do a better job.

    I'm not sure I understand thing about 1 second
    assume we wait 5 second as a delay (my camera likes 1 sec and don't make continuous shoots)
    then md_detect_motion waits for hours for detection
    I would say - 99.9% of time detector will do it's work

    Your sample shots of throwing the toys? I need to know how you do it. Because that's how I expected it to work. But it doesn't on my A610 with everything I've tried. Like I said before I can slowly wave my hand in front of the camera and by the time the shot is taken the hand has passed. What is your script and what are the camera settings used for the toy throwing examples?


    as for tweaking 100msec->30msec
    I think for my a630 will do following code change.

    void *vid_get_viewport_live_fb(){
       void **fb=(void **)0x5230;
    return fb[ *((unsigned char*)0x5240) ];
    }

    for your camera model addresses will be different

    code explanation.
    current CHDK code for histogram/zebra/md calculations uses only one of three available data buffers
    while histogram/zebra/md code tries to make calculations on outdated buffers other buffers are really changed
    every buffer is updated in 100msec sequentially
    so we are loosing 60 msec interval :-)

    I'm not sure - but I have explained this somwhere on dpreview or somwhere else

    « Last Edit: 30 / January / 2008, 05:47:49 by mx3 »
    skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

     

    Related Topics