How to mask specific cells? When doing motion detection... Canon SX30 - Completed and Working Scripts - CHDK Forum

How to mask specific cells? When doing motion detection... Canon SX30

  • 4 Replies
  • 5150 Views
Advertisements
I've got motion detection script working with continuous shooting on my Canon sx30is, for a while thanks to this forum's help.

I'm trying to figure out masking.

I can adjust the number of cells used for motion detection and it appears that I can exclude cells from motion detection or include cells for motion detection - this lets me select either cells in the center and exclude those around the perimeter or select cells around the perimeter and exclude those in the center.

Is there a way to select say the 4 or so cells in the top right corner? Just for example.

Any ideas would be great.

Here's my working script:

Code: [Select]
@title md
@param a Columns
@default a 6
@param b Rows
@default b 4
@param c Threshold (0-255)
@default c 10
@param d Comparison Interval (mSec)
@default d 1
@param e Trigger Delay (0.1 secs)
@default e 1
@param f Pixel block size
@default f 6
@param h Measure Mode(0-U,1-Y,2-V)
@default h 1
@param i Masking (0=No 1=Incl 2=Excl)
@default i 0
@param j Incl/Excl Cols & Rows
@default j 0
@param k Time-out period (s)
@default k 3600
@param n Continuous shoot (s)
@default n 7
@param s Shoot (0=f/1=nf/2=c)
@default s 2
@param u Pre-focus (0=No)
@default u 1
if j>a/2 then j=a/2
if j>b/2 then j=b/2
if j<0 then j=0
if s<0 then let s=0
if s>2 then let s=2

get_prop 102 y
if s<>2 and y=1 then
let s=2
endif

if s=0 then let g=1 else let g=0
e=e*100
k=k*1000
print "Stop - Press Shutter"
while 1
if x<>18 and u<>0 then gosub "make_focus"
md_detect_motion a, b, h, k, d, c, 1, t, i, j+1, j+1, a-j, b-j, g, f, e
if t>0 then print t, " cells detected"
if t=0 then gosub "awake"
if t>0 and u=0 and s=2 then gosub "make_focus"
if t>0 and s=1 then click "shoot_full"
if t>0 and s=2 then gosub "shoot_continuously"
if t>0 and s=3 then gosub "record_video"
if t>0 and x<>18 then
do
get_prop 210 p
until p<>1
let t=0
endif
wend

:make_focus
press "shoot_half"
do
   get_prop 210 p
until p=1
return

:shoot_continuously
press "shoot_full"
sleep n*1000
release "shoot_full"
return

:record_video
click "shoot_full"
sleep n*1000
click "shoot_full"
return

:awake
  release "shoot_half"
  if x<>18 and u=0 then
click "set"
click "set"
  endif
return

end

Re: How to mask specific cells? When doing motion detection... Canon SX30
« Reply #1 on: 06 / August / 2013, 19:48:45 »
Is there a way to select say the 4 or so cells in the top right corner? Just for example.
Yes -   i,j,k,l,m =  1 1 1 2 2  per
http://chdk.wikia.com/wiki/Motion_Detection#Function_:_md_detect_motion

Andrew Hazelton did a really nice tutorial on this subject :
http://chdk.wikia.com/wiki/Motion_Detect_Plus

« Last Edit: 06 / August / 2013, 19:51:19 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: How to mask specific cells? When doing motion detection... Canon SX30
« Reply #2 on: 06 / August / 2013, 22:25:08 »
That's the solution I was looking for.

Thanks very much.

Now, to test it out on the old SX30 - I'll let you know how it goes.

Re: How to mask specific cells? When doing motion detection... Canon SX30
« Reply #3 on: 07 / August / 2013, 08:53:50 »
OK, MD Plus works on the SX30 but... no continuous shooting capability.

Motion Detection Plus script allows me to better select the area to detect motion, but it does not allow me to use continuous shooting.

The camera will focus, take a shot, refocus and then shoot again, and so on - about 3-4 seconds between shots - way to slow for me.

Any idea if there is a script out there with the best of both worlds?

Selectable motion detection zone areas and continuous shooting?

Much appreciated...

I'm going back to searching the forum and web...

Thanks.

Re: How to mask specific cells? When doing motion detection... Canon SX30
« Reply #4 on: 07 / August / 2013, 09:08:22 »
Motion Detection Plus script allows me to better select the area to detect motion, but it does not allow me to use continuous shooting.
If I understand this,  you want to shoot continuously while there is motion detected ?

Quote
The camera will focus, take a shot, refocus and then shoot again, and so on - about 3-4 seconds between shots - way to slow for me.
You can use the set_aflock 1 command to skip the refocus part.  You might also be able to do all the motion detect stuff inside a "shoot_half" loop and avoid the whole refocus & check exposure part.  But that will only speed things up a little.

Quote
Any idea if there is a script out there with the best of both worlds? Selectable motion detection zone areas and continuous shooting?
I'm pretty certain there is not,  and here's why.  The MD detect code actually scans the LCD display buffer looking for changes. When you shoot,  there are lots of changes as the camera updates the buffer.  It one of the reasons why the md_detect function has an intial delay variable - to let the buffer "settle". You are not going to be able to get around that easliy with a script - IMHO it was take a fancy bit of rewriting / extending the C code for the md_detect function.

But I have been wrong before ....
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal