Motion detect surveillance camera "mdCCTV" - Script Writing - CHDK Forum
supplierdeeply

Motion detect surveillance camera "mdCCTV"

  • 8 Replies
  • 16355 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Motion detect surveillance camera "mdCCTV"
« on: 02 / June / 2008, 18:15:32 »
Advertisements
A new script...this one is supposed to run with the mode dial in video mode. It will possibly work on any camera except the video button ones (S series and TX1, see the MDFB script for how to modify if you are in a hurry to test it) as long as your CHDK is recent enough.

This script starts video record when it detects motion and stops video record after there hasn't been any detectable motion for a while.

This is a bit of a quick hack and as such not fully documented... but reading the documentation of the latest version of my more generic MD script http://chdk.setepontos.com/index.php/topic,471.0.html should help a lot as this is just MD after all. It uses the slow shoot method, but there shouldn't be a reason not to use fast shoot for starting if there's a big difference.

*

Offline fbalb

  • *
  • 26
  • Ixus 860
Re: Motion detect surveillance camera "mdCCTV"
« Reply #1 on: 02 / June / 2008, 18:47:16 »
Very quickly test. It's seems to work. I can only test on birds detection last week.
Thank you very much for your works

Re: Motion detect surveillance camera "mdCCTV"
« Reply #2 on: 03 / June / 2008, 10:52:28 »
Cool! Thanks for sharing! However, it seems that there is no detection in the lower space of the screen :o
I tried also to use the "mask"...and it didn't change anything.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Motion detect surveillance camera "mdCCTV"
« Reply #3 on: 03 / June / 2008, 12:12:01 »
Cool! Thanks for sharing! However, it seems that there is no detection in the lower space of the screen :o
I tried also to use the "mask"...and it didn't change anything.

Use test mode to test triggering related things. If the green grid covers your lower space too, and your pixel step is not too large, your issue is not related to this script but MD in general.

edit: to be a bit more verbose: I'd guess you may have made a typical mistake such as having a scene where there's a bright top (like the sky) and a dark bottom and then tried to put your (dark) hand over the (dark) bottom, not causing large enough of a change in luminance.
« Last Edit: 03 / June / 2008, 12:15:15 by fudgey »


Re: Motion detect surveillance camera "mdCCTV"
« Reply #4 on: 03 / June / 2008, 13:48:34 »
I already used the test mode. Even if the whole screen is covered with green squares, the squares at the bottom (at default, the script uses 6 columns and 5 rows: here I speak about the two bottom rows) are inactive: they don't react to any movment. And I also tried to use Fudgey's (yours :p) MD script, the problem does not occur. Oh and I've tried various "positions"^^ or scenes...
It's an odd thing

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Motion detect surveillance camera "mdCCTV"
« Reply #5 on: 03 / June / 2008, 14:52:43 »
I already used the test mode. Even if the whole screen is covered with green squares, the squares at the bottom (at default, the script uses 6 columns and 5 rows: here I speak about the two bottom rows) are inactive: they don't react to any movment. And I also tried to use Fudgey's (yours :p) MD script, the problem does not occur. Oh and I've tried various "positions"^^ or scenes...
It's an odd thing

Hmmm.. you're right, my a570is fails to trigger from the bottom half as well. Also the antiMD part is affected, motion in the lower half of the LCD doesn't keep video from stopping. Adding more rows won't help. Setting a mask to only cover the bottom row or two of LCD causes weird behavior: MD still doesn't trigger from the bottom of the LCD, but it will still trigger from part of the top half.  My other MD script is also affected in video mode.

If I change to P mode it triggers fine, so this is a video mode problem... (and no, this script is not compatible with still photos but that doesn't mean you can't start it in any mode and see what happens).

Furthermore, only the "normal" 640xsomething 30fps video mode seems to be failing this badly, the normal resolution 15 fps and low resolution 60fps modes seem to work fine or at least significantly better.

Maybe there's something different in the LCD buffer or the way it updates when the camera is in the video mode that is not compatible with md_detect_motion?



Re: Motion detect surveillance camera "mdCCTV"
« Reply #6 on: 06 / October / 2010, 15:41:14 »
where can i find motion detection video for my sx20is?
thanx

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Motion detect surveillance camera "mdCCTV"
« Reply #7 on: 07 / October / 2010, 09:20:41 »
where can i find motion detection video for my sx20is?
I modified the script by @fudgey using his "mdCCTV-20080603.bas" from his posting: http://chdk.setepontos.com/index.php/topic,1596.msg14337.html#msg14337

I tested this morning and seemed to work fine with the changes I made. I only tested to see if it triggered properly, but didn't have time this morning to test all of the parameters. Note: With the changes I made, the script will only work on cameras with dedicated video buttons.

Good luck with it!

PS. Save it as a BAS file and copy to your CHDK/Scripts folder to use.

Code: [Select]
rem Fudgey's Motion Detector security camera script aka "mdCCTV" -  video button cameras only
rem This CHDK uBASIC script starts video record on motion and stops when motion stops.
rem Initially developed on A570IS by fudgey - converted to work for S series and TX1 (ones with a separate video button)
rem Use a recent Allbest build (50 should be ok). Others may work.
rem "antiMD Timeout" is the required period of stillness required to stop (in seconds)
@title mdCCTV
@param a Columns
@default a 6
@param b Rows
@default b 4
@param c Threshold (0-255)
@default c 10
@param e Trigger Delay (0.1 sec)
@default e 5
@param f Channel (0U,1Y,2V,3R,4G,5B)
@default f 1
@param g Minimum video time (s)
@default g 2
@param h Pixel Step (pixels)
@default h 6
@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 MD Timeout (10s of seconds)
@default o 30
@param p antiMD Timeout (seconds)
@default p 3
@param q MD Compare Interval (ms)
@default q 7
@param r antiMD Comp.Interv. (*10ms)
@default r 20
@param z Test mode (1=on, 0=off)
@default z 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
rem cannot allow 0s delay there, may mess up MD or REC.
if g<1 then g=1
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 o<1 then o=1
if p<1 then p=1
r=r*10
p=p*1000
e=e*100
g=g*1000
o=o*10000

if z=1 then goto "test_md"

:slow_video_md
  print "motion detect armed"
  t=0
  do
    md_detect_motion a, b, f, o, q, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
  until t>0
  print "starting video record"  
  click "video"
  rem user specified minimum video length wait:
  sleep g
  gosub "slow_anti_md"
goto "slow_video_md"

:slow_anti_md
  print "stillness detect armed"
  do
    t=0
    md_detect_motion a, b, f, p, r, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
  until t<1
  if g>1 then click "video"
  print "stopping video record"
  sleep 300
return

:test_md
  print "MD test, no shooting."
  N=0
:test_md_loop
  t=0
  do
    md_detect_motion a, b, f, o, q, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
  until t>0
  N=N+1
  print t, "cells, trigger ", N
goto "test_md_loop"
« Last Edit: 07 / October / 2010, 09:27:41 by SkyWalker9 »


Re: Motion detect surveillance camera "mdCCTV"
« Reply #8 on: 12 / May / 2014, 19:37:14 »
This script was exactly what I needed!  I searched forever and could not find any motion capture scripts that recorded until motion was gone (all existing ones recorded a fixed amount of time).

I fixed up the script to work with cameras with a movie button (and could also be modified to work with either camera type)

Edit: Fixed a major bug, where it would not record continuous motion.
« Last Edit: 26 / June / 2014, 14:40:05 by JoeNobody »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal