public class WebcamMotionDetector
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_INTERVAL
Default check interval, in milliseconds, set to 500 ms.
|
Constructor and Description |
---|
WebcamMotionDetector(Webcam webcam)
Create motion detector with default parameters - threshold = 25, inertia = 0.
|
WebcamMotionDetector(Webcam webcam,
int pixelThreshold)
Create motion detector with default parameter inertia = 0.
|
WebcamMotionDetector(Webcam webcam,
int pixelThreshold,
double areaThreshold)
Create motion detector with default parameter inertia = 0.
|
WebcamMotionDetector(Webcam webcam,
int pixelThreshold,
double areaThreshold,
int interval)
Create motion detector.
|
WebcamMotionDetector(Webcam webcam,
WebcamMotionDetectorAlgorithm algorithm,
int interval)
Create motion detector.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addMotionListener(WebcamMotionListener l)
Add motion listener.
|
void |
clearInertia()
Reset inertia time to value calculated automatically on the base of interval.
|
protected void |
detect() |
WebcamMotionDetectorAlgorithm |
getDetectorAlgorithm() |
int |
getInterval() |
int |
getMaxMotionPoints() |
double |
getMotionArea()
Get percentage fraction of image covered by motion.
|
java.awt.Point |
getMotionCog()
Get motion center of gravity.
|
WebcamMotionListener[] |
getMotionListeners() |
int |
getPointRange() |
Webcam |
getWebcam()
Get attached webcam object.
|
boolean |
isMotion() |
boolean |
removeMotionListener(WebcamMotionListener l)
Removes motion listener.
|
void |
setAreaThreshold(double threshold)
Sets areaThreshold to the underlying detector algorithm, but only if the algorithm is (or
extends) WebcamMotionDetectorDefaultAlgorithm
|
void |
setInertia(int inertia)
Set motion inertia (time when motion is valid).
|
void |
setInterval(int interval)
Motion check interval in milliseconds.
|
void |
setMaxMotionPoints(int i) |
void |
setPixelThreshold(int threshold)
Sets pixelThreshold to the underlying detector algorithm, but only if the algorithm is (or
extends) WebcamMotionDetectorDefaultAlgorithm
|
void |
setPointRange(int i) |
void |
start() |
void |
stop() |
public static final int DEFAULT_INTERVAL
public WebcamMotionDetector(Webcam webcam, WebcamMotionDetectorAlgorithm algorithm, int interval)
webcam
- web camera instancemotion
- detector algorithm implementationinterval
- the check interval (in milliseconds)public WebcamMotionDetector(Webcam webcam, int pixelThreshold, double areaThreshold, int interval)
webcam
- web camera instancepixelThreshold
- intensity threshold (0 - 255)areaThreshold
- percentage threshold of image covered by motioninterval
- the check intervalpublic WebcamMotionDetector(Webcam webcam, int pixelThreshold, double areaThreshold)
webcam
- web camera instancepixelThreshold
- intensity threshold (0 - 255)areaThreshold
- percentage threshold of image covered by motion (0 - 100)public WebcamMotionDetector(Webcam webcam, int pixelThreshold)
webcam
- web camera instancepixelThreshold
- intensity threshold (0 - 255)public WebcamMotionDetector(Webcam webcam)
webcam
- web camera instancepublic void start()
public void stop()
protected void detect()
public boolean addMotionListener(WebcamMotionListener l)
l
- listener to addpublic WebcamMotionListener[] getMotionListeners()
public boolean removeMotionListener(WebcamMotionListener l)
l
- motion listener to removepublic int getInterval()
public void setInterval(int interval)
interval
- the new motion check interval (ms)DEFAULT_INTERVAL
public void setPixelThreshold(int threshold)
threshold
- the pixel intensity difference thresholdWebcamMotionDetectorDefaultAlgorithm.setPixelThreshold(int)
public void setAreaThreshold(double threshold)
threshold
- the percentage fraction of image areaWebcamMotionDetectorDefaultAlgorithm.setAreaThreshold(double)
public void setInertia(int inertia)
clearInertia()
method must be used.inertia
- the motion inertia time in millisecondsclearInertia()
public void clearInertia()
public Webcam getWebcam()
public boolean isMotion()
public double getMotionArea()
public java.awt.Point getMotionCog()
public WebcamMotionDetectorAlgorithm getDetectorAlgorithm()
public void setMaxMotionPoints(int i)
public int getMaxMotionPoints()
public void setPointRange(int i)
public int getPointRange()
Copyright © 2012-2018 Bartosz Firyn (SarXos). All Rights Reserved.