CHDK Motion Detect Plus Script - page 2 - Script Writing - CHDK Forum supplierdeeply

CHDK Motion Detect Plus Script

  • 31 Replies
  • 23372 Views
Re: CHDK Motion Detect Plus Script
« Reply #10 on: 10 / June / 2012, 06:28:11 »
Advertisements
Hi there :) Thanx for your script and your time/work Andrew Hazelden

Unfortunately this script does not work correctly on ixus 220 aka elph 300hs.

"There appears to be an issue where the motion detection function doesn't reset for the next photo unless the image review mode is disabled. To disable the image review feature, open the main Canon menu by pressing the menu button on your camera. Scroll down to the option labeled Review and set it to Off."

Even if I set review to OFF. The problem persist.

I have the lastest stable build: ixus220_elph300hs-100c-1.0.0-1892-full_ALPHA

Re: CHDK Motion Detect Plus Script
« Reply #11 on: 17 / June / 2012, 06:14:25 »
Hi Frojnd.

I'm interested in hearing more about the Motion Detection Plus script issue on the Canon IXUS 220 camera. Could you describe what happens when you try to run the script? Does the software get stuck in a continuous photo taking loop?

Regards,
Andrew
Canon SD780IS

Re: CHDK Motion Detect Plus Script
« Reply #12 on: 21 / June / 2012, 04:29:57 »
Hi Frojnd.

It appears the issue you are experiencing is due to the script's motion detection "trigger sensitivity" threshold. I have an updated script that has a lower default sensitivity and provides control over the parameter.

After I run a camera test on my lawn for a day to make sure it works I will post the improved script.
Canon SD780IS

Re: CHDK Motion Detect Plus Script
« Reply #13 on: 25 / June / 2012, 06:01:49 »
Hi andrewhazelden,

When I try to run the script, the grid naturally shows up and then whenthere is a change in a position, in my case it was rather coludy and script recognized the movement of the clouds and start shooting. But it shoots every n seconds (I don't know how many seconds n was exactly)...

I think the software gets stuck in a continuous photo taking loop.

I'd be more then glad to try new version :) I wasn't able to actually shoot any light burst with this camera and your script has the most potential :)


Re: CHDK Motion Detect Plus Script
« Reply #14 on: 25 / June / 2012, 13:47:59 »
Hi Frojnd.

I have created Motion Detect Plus v0.2.

This upgrade adds a "Motion Threshold" parameter that lets you control the responsiveness of the motion detection feature. If the camera to takes photos continuously increase the "Motion Threshold" setting for a reduced motion detection response.

Here are several typical motion threshold levels:
12=Sun 24=Cloudy 36=Dawn/Dusk

I would like to thank Waterwingz for his help in troubleshooting the issue.

Code: [Select]
--[[
@title Motion Detect Plus
rem Version 0.2.1 - June 25, 2012 - 2:25pm

rem by Andrew Hazelden
rem email:  andrewhazelden@gmail.com 
rem blog:   [url=http://www.andrewhazelden.com/]www.andrewhazelden.com/[/url]

rem This script adds a repetitive shot mode and is
rem based upon the standard "motion.lua" script

rem Make sure to disable Review Mode in the Canon menus.

rem Standard sensitivity threshold levels: 12=Sun 24=Cloudy 36=Dawn/Dusk

rem If the camera to takes photos continuously increase the
rem threshold setting level for a reduced motion detection
rem responsiveness.

rem (a higher motion threshold number = lower responsiveness)

rem Version History
rem ---------------
rem Version 0.2
rem Created June 25, 2012
rem Added a "Motion Threshold" parameter

rem Version 0.1
rem Created on Feb 26, 2012
rem Initial Release of Motion Detect Plus

@param x Motion Threshold

@param y Start Delay (min)
@param z Start Delay (sec)

@param g Draw Grid 0=No 1=Yes
@param a Grid Columns
@param b Grid Rows

@param i Region 0=No 1=In 2=Out

@param j Start Column
@param l End Column
@param k Start Row
@param m End Row

rem default delay values
@default y 0
@default z 3


rem default motion threshold
@default x 24

rem default grid values
@default g 1
@default a 3
@default b 3

rem enabled grid cells
@default i 0
@default j 0
@default k 0
@default l 0
@default m 0
--]]


-- make sure the start column is smaller then the end column
if j>l then
 j=l
end

-- make sure the start row is smaller then the end row
if k>m then
 k=m
end

--make sure the region number is valid
if i>2 then
 i=0
end

-- Motion detection variables
-- a=6       -- columns to split picture into
-- b=6       -- rows to split picture into
c=1         -- measure mode (Y,U,V R,G,B) U=0, Y=1, V=2, R=3, G=4, B=5
d=300000    -- timeout (mSec)
e=200       -- comparison interval (msec) - less than 100 will slow down other CHDK functions
-- f=5         -- threshold (difference in cell to trigger detection)
-- g=1       -- draw grid (0=no, 1=yes)   
h=0         -- not used in LUA - in uBasic is the variable that gets loaded with the number of cells with motion detected
-- i=0         -- region masking mode: 0=no regions, 1=include, 2=exclude
-- j=0         --      first column
-- k=0         --      first row
-- l=0         --      last column
-- m=0         --      last row
n=0         -- optional parameters  (1=shoot immediate)
o=2         -- pixel step
p=0         -- triggering delay (msec)


-- Other variables
q=0         -- the number of shots taken
-- r=get_tick_count()  -- beginning of script timer value

-- Start the delay timer
cls()
print("Typical Motion Threshold")
print("12=Sun 24=Cloudy 36=Dawn")

if y>0 then
print( y .. " min " .. z .. " sec to start...")
else
print( z .. " sec to start...")
end

sleep( (z*1000)+(y*1000*60) )


-- Start the motion detection loop
cls()
print("Starting Motion Detection")
play_sound(3)   --plays the self timer sound effect

repeat
zones = md_detect_motion( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)

--check if the zones value is nil due to pausing the script
if( zones ~= nil) then
if( zones > 0 ) then
shoot()
cls()
q=q+1  -- Increment the shots taken counter
print(q .. " Shots Taken")
end
end



until ( false )


« Last Edit: 20 / August / 2012, 10:20:45 by andrewhazelden »
Canon SD780IS

Re: CHDK Motion Detect Plus Script
« Reply #15 on: 20 / August / 2012, 10:16:24 »
I have released Motion Detect Plus version 0.3. It improves the motion threshold setting.

It can be downloaded here:
CHDK-Motion-Detect-Plus-v0.3.zip

Code: [Select]
--[[
@title Motion Detect Plus
rem Version 0.3 - August 20, 2012

rem by Andrew Hazelden
rem email:  andrewhazelden@gmail.com 
rem blog:   [url=http://www.andrewhazelden.com/]www.andrewhazelden.com/[/url]

rem This script adds a repetitive shot mode and is
rem based upon the standard "motion.lua" script

rem Make sure to disable Review Mode in the Canon menus.

rem Standard sensitivity threshold levels: 12=Sun 24=Cloudy 36=Dawn/Dusk

rem If the camera takes photos continuously increase the
rem threshold setting level for a reduced motion detection
rem responsiveness.

rem (a higher motion threshold number = lower responsiveness)

rem Version History
rem ---------------

rem Version 0.3
rem Aug 20, 2012
rem Improved motion threshold settings


rem Version 0.2
rem Created June 25, 2012
rem Added a "Motion Threshold" parameter

rem Version 0.1
rem Created on Feb 26, 2012
rem Initial Release of Motion Detect Plus

@param f Motion Threshold

@param y Start Delay (min)
@param z Start Delay (sec)

@param g Draw Grid 0=No 1=Yes
@param a Grid Columns
@param b Grid Rows

@param i Region 0=No 1=In 2=Out

@param j Start Column
@param l End Column
@param k Start Row
@param m End Row

rem default delay values
@default y 0
@default z 3


rem default motion threshold
@default f 24

rem default grid values
@default g 1
@default a 3
@default b 3

rem enabled grid cells
@default i 0
@default j 0
@default k 0
@default l 0
@default m 0
--]]


-- make sure the start column is smaller then the end column
if j>l then
 j=l
end

-- make sure the start row is smaller then the end row
if k>m then
 k=m
end

--make sure the region number is valid
if i>2 then
 i=0
end

-- Motion detection variables
-- a=6       -- columns to split picture into
-- b=6       -- rows to split picture into
c=1         -- measure mode (Y,U,V R,G,B) U=0, Y=1, V=2, R=3, G=4, B=5
d=300000    -- timeout (mSec)
e=200       -- comparison interval (msec) - less than 100 will slow down other CHDK functions
-- f=5         -- threshold (difference in cell to trigger detection)
-- g=1       -- draw grid (0=no, 1=yes)   
h=0         -- not used in LUA - in uBasic is the variable that gets loaded with the number of cells with motion detected
-- i=0         -- region masking mode: 0=no regions, 1=include, 2=exclude
-- j=0         --      first column
-- k=0         --      first row
-- l=0         --      last column
-- m=0         --      last row
n=0         -- optional parameters  (1=shoot immediate)
o=2         -- pixel step
p=0         -- triggering delay (msec)


-- Other variables
q=0         -- the number of shots taken
-- r=get_tick_count()  -- beginning of script timer value

-- Start the delay timer
cls()
print("Typical Motion Threshold")
print("12=Sun 24=Cloudy 36=Dawn")

if y>0 then
print( y .. " min " .. z .. " sec to start...")
else
print( z .. " sec to start...")
end

sleep( (z*1000)+(y*1000*60) )


-- Start the motion detection loop
cls()
print("Starting Motion Detection")
play_sound(3)   --plays the self timer sound effect

repeat
zones = md_detect_motion( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)

--check if the zones value is nil due to pausing the script
if( zones ~= nil) then
if( zones > 0 ) then
shoot()
cls()
q=q+1  -- Increment the shots taken counter
print(q .. " Shots Taken")
end
end



until ( false )
« Last Edit: 16 / September / 2012, 08:28:11 by andrewhazelden »
Canon SD780IS

Re: CHDK Motion Detect Plus Script
« Reply #16 on: 16 / September / 2012, 08:26:09 »
Today I released version 0.3.1 of the Motion Detect Plus Script.

You can download the CHDK Motion Detect Plus script here:
chdk-motion-detect-plus.zip

This version improves the script by reducing the continuous photo issue and adds a "Number of Shots" attribute that takes multiples shots during a motion detection event.

Code: [Select]
--[[
@title Motion Detect Plus
rem Version 0.3.1 - Sept 16, 2012
rem Build 27

rem This file is a CHDK LUA script and should have the name "motionp.lua"

rem by Andrew Hazelden
rem email: andrewhazelden@gmail.com
rem blog: [url=http://www.andrewhazelden.com]www.andrewhazelden.com[/url]

rem This script adds a repetitive shot mode and is
rem based upon the standard "motion.lua" script

rem Make sure to disable Review Mode in the Canon menus.

rem Standard sensitivity threshold levels: 12=Sun 24=Cloudy 36=Dawn/Dusk

rem If the camera takes photos continuously increase the
rem threshold setting level for a reduced motion detection
rem responsiveness.

rem (a higher motion threshold number = lower responsiveness)

rem Version History
rem ---------------

rem Version 0.3.1
rem Sept 16, 2012
rem Changed the zones variable to avoid a naming conflict.
rem Added a "Number of Shots" variable that takes a burst of photos
rem during a motion detection event.

rem Version 0.3
rem Aug 20, 2012
rem Improved motion threshold settings

rem Version 0.2
rem Created June 25, 2012
rem Added a "Motion Threshold" parameter

rem Version 0.1
rem Created on Feb 26, 2012
rem Initial Release of Motion Detect Plus

@param f Motion Threshold
@default f 24
@range f 0 100

rem Script start delay values
@param y Start Delay (min)
@default y 0
@param z Start Delay (sec)
@default z 3

rem default number of shots taken during a motion detection event
@param w Number of Shots
@default w 1

@param g Draw Grid 0=No 1=Yes
@default g 1
@range g 0 1

@param a Grid Columns
@param b Grid Rows
@default a 3
@default b 3

@param i Region 0=No 1=In 2=Out
@default i 0
@range i 0 2

rem Enabled grid cells
@param j Start Column
@param l End Column
@param k Start Row
@param m End Row
@default j 0
@default k 0
@default l 0
@default m 0

--]]

shots=0 -- photos taken counter


-- make sure number of shots is positive
if w<0 then
  w=1
end
num_shots = w


-- make sure the start column is smaller then the end column
if j>l then
 j=l
end

-- make sure the start row is smaller then the end row
if k>m then
 k=m
end

--make sure the region number is valid
if i>2 then
 i=0
end

-- Motion detection variables
-- a=6 -- columns to split picture into
-- b=6 -- rows to split picture into
c=1 -- measure mode (Y,U,V R,G,B) U=0, Y=1, V=2, R=3, G=4, B=5
d=300000 -- timeout (mSec)
e=200 -- comparison interval (msec) - less than 100 will slow down other CHDK functions
-- f=5    -- threshold (difference in cell to trigger detection)
-- g=1 -- draw grid (0=no, 1=yes)  
h=0 -- not used in LUA - in uBasic is the variable that gets loaded with the number of cells with motion detected
-- i=0    -- region masking mode: 0=no regions, 1=include, 2=exclude
-- j=0    --    first column
-- k=0    --    first row
-- l=0    --    last column
-- m=0    --    last row
n=0 -- optional parameters (1=shoot immediate)
o=2 -- pixel step
p=0 -- triggering delay (msec)

-- Other variables

-- r=get_tick_count()  -- beginning of script timer value

-- Start the delay timer
cls()
print("Typical Motion Threshold")
print("12=Sun 24=Cloudy 36=Dawn")

if y>0 then
print( y .. " min " .. z .. " sec to start...")
else
print( z .. " sec to start...")
end

sleep( (z*1000)+(y*1000*60) )

-- Start the motion detection loop
cls()
print("Starting Motion Detection")
play_sound(3) --plays the self timer sound effect

repeat
md_zone = md_detect_motion( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
cls()

--check if the md_zone value is nil due to pausing the script
if( md_zone ~= nil) then
if( md_zone > 0 ) then
--shoot multiple photos in a burst using (Number of Shots)
if(num_shots>0) then
burst = num_shots
repeat
shoot()
cls()
shots=shots+1  -- Increment the shots taken counter
burst=burst-1  -- update the photo burst counter
until ( burst==0 )
print(shots .. " Shots Taken" )
sleep(250)
end
end
end
until ( false )
Canon SD780IS

Re: CHDK Motion Detect Plus Script
« Reply #17 on: 16 / September / 2012, 09:09:39 »
@andrewhazelden :  I can't believe that I have not suggested / requested that you make a wiki page out of this thread. The first posting is especially great stuff and when I finally get my "Best of the Wiki" page done, this one would be near the top.

Ported :   A1200    SD940   G10    Powershot N    G16


Re: CHDK Motion Detect Plus Script
« Reply #18 on: 19 / September / 2012, 19:06:26 »
Hi Waterwingz.

Thanks for the suggestion of adding the Motion Detect Plus script to the CHDK Wiki. When I get a moment I will write up a new wiki page with the latest info.
Canon SD780IS

*

Offline brizo

  • *
  • 15
CHDK Motion Detect Plus Script
« Reply #19 on: 20 / September / 2012, 07:20:41 »
This looks really good : )

 

Related Topics