I need help with programing a timer using sound and presence detection. My goal is to have a sound play when a presence is not detected for 2 minutes, and the sound stops playing when a presence is detected. Currently I'm taking this project in steps, the sketch draws a ellipse when a presence is not detected and disappear when a presence detected. I'm stuck with the timing part, the timing only works during the beginning of the sketch. Ideally I would like to have a ellipse drawn when a presence is not detected for 3 seconds, and disappear when a presence detected. Once I figure this out then I'll try it with sound. Please help. The part of the code that's not working is heightened in red.
Here's my code:
/*
flob - A fast multi-blob detector and tracker using flood-fill algorithms
http://s373.net/code/flob copyright (c) André Sier 2008-2010
steps:
0. construct a flob object with video, width and height:
sets desired world coordinate return values for data
1. configure tracker (setOm, setTresh, setFade, setMirror, setBlur, setSrcImage, ...)
2. when new video frame arrives, pass it to binarize and the to one of the tracking
methods available, which returns an ArrayList with the blobs
3. access each blob individually and plug in the values from there to your program
size(700,500,OPENGL);
frameRate(fps);
rectMode(CENTER);
// init video data and stream
video = new Capture(this, videores, videores, (int)fps);
// init blob tracker
// flob uses construtor to specify srcDimX, srcDimY, dstDimX, dstDimY
// srcDim should be video input dimensions
// dstDim should be desired output dimensions
flob = new Flob(video, width,height);
flob = new Flob(video, this);
flob = new Flob(videores, videores, width, height);
flob.setTresh(tresh); //set the new threshold to the binarize engine
flob.setThresh(tresh); //typo
flob.setSrcImage(videotex);
flob.setImage(videotex); // pimage i = flob.get(Src)Image();
flob.setBackground(video); // zero background to contents of video
flob.setBlur(0); //new : fastblur filter inside binarize
flob.setMirror(true,false);
flob.setOm(0); //flob.setOm(flob.STATIC_DIFFERENCE);
flob.setOm(1); //flob.setOm(flob.CONTINUOUS_DIFFERENCE);
flob.setFade(fade); //only in continuous difference
/// or now just concatenate messages
flob.setThresh(tresh).setSrcImage(videotex).setBackground(video)
.setBlur(0).setOm(1).setFade(fade).setMirror(true,false);;
font = createFont("monaco",9);
textFont(font);
blobs = new ArrayList();
}