MDFB2013 - updating the fastest CHDK motion detection script

  • 94 Replies
  • 12471 Views
  • Publish
    MDFB2013 - updating the fastest CHDK motion detection script
    « on: 29 / October / 2013, 19:45:28 »
    Advertisements
    In my "spare" time,  I've been plugging away at an update to fudgey's classic MDFB-080914.bas script. It's now a little over five years old and still acknowledged as the best script for lightning photography! But it is probably due for a bit of an upgrade. 

    From the included text file section on changes in 2013 :

    Quote
    MDFB 2013 v1.1 :
    - made a single script from the video button and no video button versions
    - converted from uBASIC to Lua for better readability and speed
    - modified @param settings to use new CHDK capabilites easing user input
    - improved test mode using the new md_detect_motion() grid options
    - tweaked some of the timing parameters between shots for better stability
    - added the ability to stop the script by pressing any key - stops after  next shot
    - added an ugly looking splash screen (you can disable it)
    - added power saving / stealth mode support for display or backlight disable
    - added automatic switch to shooting mode if camera is in playback
    - added disable for flash and focus assist lights
    - added user configurable logging
    - updated the excellent user guide!

    I've tested on several cameras - with and without seperate video buttons but I could really use some fresh eyes looking at this.   I'll give it a couple of days for feedback, do some more of my own testing, and update the MD wiki page at that point.


    Update  2015MAR16 :  latest version of script & text files are here :  MDFB2013.lua & MDFB2013.txt

    Note :  there is a wiki page that describes how CHDK motion detection works : Motion Detection
    « Last Edit: 02 / May / 2015, 10:02:02 by waterwingz »

    *

    Offline n6mod

    • *
    • 15
  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #1 on: 23 / December / 2013, 21:12:41 »
    Thanks for the update! This is a great script, and I'm happy to see it ported to Lua.

    I'm looking for a bit of advice on the way to get the best performance out of a small change to the script.

    I'd actually like to use this for a combined timelapse/motion detection script. The initial application is also the easiest to explain: timelapses of thunderstorms.

    I'd like to have the MD script running in fast mode, but fire a shot anyway once per timeout. Then I can set the timeout to the desired timelapse interval, and get a timelapse movie that includes all the lightning. :)

    I tried the naive implementation, adding shoot() to the inner until() loop in fast_md(). This works, but the total cycle time of that shot is about 4s. If I'm aiming for a 15s timelapse, that means there's only about a 70% chance of catching a motion event.

    Is there a different strategy that will reduce the cycle time of the shot?

    I suppose the ultimate answer to this would be a change to md_detect_motion to add a 'fire on timeout' flag, but that's probably beyond my ability. (I haven't looked at that code.)

    Any suggestions would be appreciated.

  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #2 on: 23 / December / 2013, 22:09:06 »
    I tried the naive implementation, adding shoot() to the inner until() loop in fast_md(). This works, but the total cycle time of that shot is about 4s. If I'm aiming for a 15s timelapse, that means there's only about a 70% chance of catching a motion event. Is there a different strategy that will reduce the cycle time of the shot?
    The problem you are having is related using the shoot() command, which causes the camera to focus and set exposure.  However, in  the inner loop that has already been done by the press("shoot_half") statement so there is no need to do it twice.

    Try this :

    Code: [Select]
    function fast_md()
        splash("Fast Reaction Photo MD")
        repeat 
                press("shoot_half")
                repeat sleep(10) until (get_shooting()==true)
                update_display_state()
                motion = detect_motion(e,f,1,9)
                if ( motion == 0 ) then
                     click("shoot_full_only")
                else                 
                     if (post_shot_delay> 0) then sleep(post_shot_delay) end
                     release("shoot_full")
                end
                release("shoot_half")
                repeat sleep(10) until (get_shooting()==false)
                wait_click(50)                         
        until not( is_key("no_key"))
    end
    Sorry - have not had time to test this myself. If it doesn't work, I'll take a look later this week when I have my development machine and cameras back.

    Note : there was also a one second delay related to the need to turn the backlight off after every shot.  If we use the new set_lcd_display() command that is no longer needed.  We can look at that after we get the loop time down.

    Update : edit to script snippet to enable backlight control.  And I actually tested it too.
    « Last Edit: 10 / May / 2015, 10:24:22 by waterwingz »

    *

    Offline n6mod

    • *
    • 15
  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #3 on: 24 / December / 2013, 02:34:58 »
    Wow, thanks for the quick reply!

    That's working great, the cycle time is down in the neighborhood of 2s. Now all I need is a thunderstorm. Usually every afternoon, but not this trip.

    Merry Christmas from Malaysia.  :xmas


  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #4 on: 24 / December / 2013, 12:13:32 »
    That's working great, the cycle time is down in the neighborhood of 2s. Now all I need is a thunderstorm. Usually every afternoon, but not this trip.
    Great news! 

    With a little more work, it should be possible to get closer to one second using the tricks from this script :  http://chdk.wikia.com/wiki/Fast_Shooter_Intervalometer

    I'm a little reluctant to post a script mod without being able to test but if I get a few quiet minutes I'll take a a look at it.

    Going much faster than that might need some parts of lapser's shot histogram request experimental version of CHDK.

    Quote
    Merry Christmas from Malaysia.  :xmas
    And to you too.

  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #5 on: 13 / January / 2014, 23:02:40 »
    Your nice MDFB update seems to working with my S110 but I get this screen all the time when I push down the shutter button.  I don't think it is related to your script as I get it for other things as well.  Any idea on how to turn this off?  Thanks.

  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #6 on: 13 / January / 2014, 23:10:06 »
    Your nice MDFB update seems to working with my S110 but I get this screen all the time when I push down the shutter button.  I don't think it is related to your script as I get it for other things as well.  Any idea on how to turn this off?  Thanks.
    Its a "feature" that was added with the release of CHDK 1.2.0.   The change is documented here : http://chdk.wikia.com/wiki/Releases#1.2 - look at the last change in the list.

    Strange that you get it when pressing the shutter button.  On most cameras it pops up all by itself after a two second delay in <ALT> mode when no key has been pressed.   >:(

    Hint :  CHDK Settings   ->  Menu Settings   ->  Show <ALT> Help Screen [ * ]

  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #7 on: 13 / January / 2014, 23:30:58 »
    Thanks.  That did it.  I turned it off.  By the way, I had good luck last summer with lightning using MDFB.  I kept the Threshold at about 15 or 16, locked focus, and set the mode to P.  It worked pretty well.  Do you do anything different than that for lightning?  Here's one of the pics I got last summer.  The S100 chose f2.0 and an ISO of 640 but I had the ISO limit set to that as I don't like noise.  I'm thinking of setting the ISO limit to 400 this coming season.  Thoughts?


  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #8 on: 13 / January / 2014, 23:33:12 »
    Thoughts?
    Why tamper with perfection?  That is an amazing shot.  I'm truly jealous!

  • Publish
    Re: MDFB2013 - updating the fastest CHDK motion detection script
    « Reply #9 on: 13 / January / 2014, 23:41:52 »
    Thanks.  As you well know it's only one of many hundreds of failed shots.  Hope to get some more of those this spring and summer.  I'm rigging up some of those USB 12V/5V batteries to 3.7 volts by following Andrew Hull's, from the Forums, plans on powering external batteries to powershots so I can leave the cams out all night for more chances.  I use underwaters housings with a bit of a ledge on them to keep the rain droplets off the lens area.  Anyway, thanks for the updated script, it's served me well in the past.

     

    Related Topics