supplierdeeply

NO ACTIVITY = TAKE SNAP!...anyone?

  • 13 Replies
  • 6966 Views
  • Publish
    NO ACTIVITY = TAKE SNAP!...anyone?
    « on: 12 / April / 2008, 08:32:15 »
    Advertisements
    Hi,
    i was looking for a script that could take a snap as soon as the camera detects zero activity. this would be helpful for taking snaps of large crowds of people(10-15) without blurring. it was originally an idea given by Barney. i talked to him. he said for more information and scripting i should be contacting MX3.
    MX3 can u please throw some light on this issue?

    Thanks
    sk

  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #1 on: 12 / April / 2008, 08:54:56 »
    You could use the md_get_cell_diff function. It drove me nutty without array support though.

  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #2 on: 12 / April / 2008, 10:27:42 »
    thanks jonnythe but i would like to let u know that am totally unequipped with programing under uBASIC. i was wondering if that kind of a script exists or is in the process of being built by someone.

    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #3 on: 12 / April / 2008, 11:42:04 »
    Well, here's a quick hack for an anti MD script. I tested it really quickly one minute ago: I started the script, walked in front of the camera quickly, then took a chair, sat on it and kept still and it took a shot of me.

    The script has a lot in common with my fast MD with burst/review/mask I posted yesterday here: http://chdk.setepontos.com/index.php/topic,471.msg9169.html#msg9169. That script has extensive documentation, be sure to read it before asking any questions. This script has mostly the same parameters, but the multipliers for the timing parameters have been changed to suit this application better. Again, please read the documentation to that other script (on this Script Writing board), because I'm afraid you really need to understand many of the script's parameters quite well before you can really know how fiddle with it properly.

    This script works by using the same md_detect_motion command every md script uses, but the other way around: you arm motion detect but set a short timeout (2 seconds by default). If motion is detected, MD gets automatically armed again and nothing happens. But if that 2 second timeout passes before any motion is detected, the script shoots. So you really need to set MD in a way that it's just suitably sensitive to motion! I think this is even harder for this script than for normal MD.

    After shooting, the script ends.

    There's a fast shoot and auto shoot mode (ie allow autofocus/autoexposure either on script start or right before shooting) and also a burst/review mode (depending on if you start the script with your camera in continous drive mode or not).

    Here it is:

    Code: [Select]
    rem Anti-Motion Detector script aka Stillness Detector
    rem Developed on A570IS by fudgey on Allbest #49. May work on any camera.
    rem This script runs motion detection in a short loop and shoots if MD exits
    rem due to timeout instead of motion.
    rem Do not decrease compare interval below LCD refresh (possibly 30 ms)!
    rem Do not decrease timeout below or even close to trigger delay!
    @title Anti-Motion Detect v080412
    @param a Columns
    @default a 6
    @param b Rows
    @default b 4
    @param c Threshold (0-255)
    @default c 10
    @param g Burst/Review time (s)
    @default g 0
    @param d Compare Interval (*0.01s)
    @default d 20
    @param h Pixel Step (pixels)
    @default h 4
    @param f Channel (0U,1Y,2V,3R,4G,5B)
    @default f 1
    @param n MD Timeout (*0.1s)
    @default n 20
    @param e Trigger Delay (*0.1s)
    @default e 1
    @param i Masking (0=No 1=Mask 2=Use)
    @default i 0
    @param j Mask Columns Left
    @default j 0
    @param k Mask Columns Right
    @default k 0
    @param l Mask Rows Top
    @default l 0
    @param m Mask Rows Bottom
    @default m 0
    @param o Slow Shoot (0=No 1=Yes)
    @default o 0
    if a<1 then a=1
    if b<1 then b=1
    if i<0 then i=0
    if i>2 then i=2
    if j<0 then j=0
    if k<0 then k=0
    if l<0 then l=0
    if m<0 then m=0
    if j>a then j=a
    if k>a then k=a
    if l>b then l=b
    if m>b then m=b
    if g<0 then g=0
    if f<0 then f=1
    if f>5 then f=1
    if f=0 then print "Channel: U chroma"
    if f=1 then print "Channel: Luminance"
    if f=2 then print "Channel: V chroma"
    if f=3 then print "Channel: Red"
    if f=4 then print "Channel: Green"
    if f=5 then print "Channel: Blue"
    if n<1 then n=1
    e=e*100
    g=g*1000
    n=n*100
    if o>0 then goto "slow_anti_md"

    rem fast branch allows focus/exposure at startup, not after detection
    :fast_anti_md
    press "shoot_half"
    do
      t=0
      md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
    until t<1
    press "shoot_full"
    let X=get_tick_count
    :contloop1
    let U=get_tick_count
    let V=(U-X)
    if V<g then goto "contloop1"
    release "shoot_full" 
    goto "cleanup"

    rem slow branch allows focus/exposure after detection
    :slow_anti_md
    do
      t=0
      md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
    until t<1
    if g>1 then goto "contshoot2" else shoot
    goto "cleanup"

    :contshoot2
    press "shoot_full"
    let X=get_tick_count
    :contloop2
    let U=get_tick_count
    let V=(U-X)
    if V<g then goto "contloop2"
    release "shoot_full" 
    goto "cleanup"

    :cleanup
    print "Anti-MD finished."
    end


    edit: I'm amending the above script with this licensing statement:

    Copyright 2008 fudgey

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>

    « Last Edit: 19 / January / 2014, 13:39:19 by fudgey »


  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #4 on: 13 / April / 2008, 07:38:20 »
    thanks fudgey. am new to all this scripting thing. but i'll give it a try in the manner u have explained and keep u updated on it.

    *

    Online zeno

    • *****
    • 847
  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #5 on: 13 / April / 2008, 09:30:37 »
    Thanks Fudgey. This and your fast MD script are exactly what I needed!
    A570, S100, Ixus 127
    Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #6 on: 17 / April / 2008, 10:17:37 »
    hi fudgey. i just tested ur script and it seems to be working pretty nicely...almost in the manner i wanted. i'll beta test it :) and tell u if i have something to comment upon.

    Thanks friend.

    *

    Offline a710is

    • ****
    • 250
    • A710 IS
  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #7 on: 17 / April / 2008, 10:36:17 »
    nice. in order to take automatically take sharp long exposures or long zoom pictures I believe there's need for more sensitivity. how to set it?
    nevertheless, it's a great feature.


    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #8 on: 17 / April / 2008, 13:17:01 »
    nice. in order to take automatically take sharp long exposures or long zoom pictures I believe there's need for more sensitivity. how to set it?
    nevertheless, it's a great feature.

    First (if you didn't already do so), try reading the documentation to the other script I referred to. I don't think there should be problems with using long zoom if the camera is properly mounted and there's enough light.

    But motion detection has problems when it gets dark, because the LCD viewfinder image it uses to detect motion becomes very noisy. So in dark you will have to set a normal motion detect script to be insensitive or you will get pictures constantly, and in this anti motion detection you will never get a shot if MD is too sensitive. In other words, if you are having trouble getting the anti-MD to shoot in dark, the first step should probably be to increase MD threshold. Of course if you do that, you will have to have a lot more motion to keep the script from shooting.

    There's one way to improve this I can think of, and that involves adding noise reduction code to md_detect_motion, for example by making it average (or sum up) consecutive LCD images and compare these averages (or sums) instead of pure unprocessed images.

    Finding a way to override the camera's automatic control of the LCD viewfinder brightness could sometimes help as well if you are able to decide the correct setting better than the camera OS is (I'm not sure if I would be).


    Oh and also remember that whatever you shoot, by default the script monitors luminance. If you're dressed in dark blue clothes jumping around in front of a dark red wall, chances are the scene luminance is pretty constant (dark on dark) and you'd be better off selecting another channel as well as turning on the lights.

    *

    Offline a710is

    • ****
    • 250
    • A710 IS
  • Publish
    Re: NO ACTIVITY = TAKE SNAP!...anyone?
    « Reply #9 on: 17 / April / 2008, 15:18:46 »
    sorry, I've been pretty tired today, it's true I should've read the rest of your post but I've ommited it out of fatigue. I'll read tomorrow when hopefully I'll be more alert.

     

    Related Topics