You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motion detector should trigger the motion event and stay in "motion" state for the time when motion is in progress and the intertia time defined as one of the parameters. Due to bug in the implementation it caused false positive events about new motion started when previous motion was already in progress.
importjava.io.IOException;
importcom.github.sarxos.webcam.Webcam;
importcom.github.sarxos.webcam.WebcamMotionDetector;
importcom.github.sarxos.webcam.WebcamResolution;
/** * The goal of this example is to demonstrate the idea behind detecting that * motion has stopped. * * @author Bartosz Firyn (sarxos) */publicclassDetectMotionEventsExample {
Webcamwebcam;
WebcamMotionDetectordetector;
publicDetectMotionEventsExample() {
webcam = Webcam.getDefault();
webcam.setViewSize(WebcamResolution.VGA.getSize());
detector = newWebcamMotionDetector(webcam);
detector.setInterval(200); // one check per 200 msdetector.setInertia(2000); // keep "motion" state for 2 secondsdetector.start();
Threadt = newThread("motion-printer") {
@Overridepublicvoidrun() {
booleanmotion = false;
longnow = 0;
while (true) {
now = System.currentTimeMillis();
if (detector.isMotion()) {
if (!motion) {
motion = true;
System.out.println(now + " MOTION STARTED");
}
} else {
if (motion) {
motion = false;
System.out.println(now + " MOTION STOPPED");
}
}
try {
Thread.sleep(50); // must be smaller than interval
} catch (InterruptedExceptione) {
e.printStackTrace();
}
}
}
};
t.setDaemon(true);
t.start();
}
publicstaticvoidmain(String[] args) throwsIOException {
newDetectMotionEventsExample();
System.in.read(); // keep program open
}
}
The text was updated successfully, but these errors were encountered:
Motion detector should trigger the motion event and stay in "motion" state for the time when motion is in progress and the intertia time defined as one of the parameters. Due to bug in the implementation it caused false positive events about new motion started when previous motion was already in progress.
The text was updated successfully, but these errors were encountered: