com.github.sarxos.webcam
public class WebcamMotionDetector extends Object
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_AREA_THREASHOLD
Default percentage image area fraction threshold (set to 0.2%).
|
static int |
DEFAULT_INTERVAL
Default check interval (in milliseconds, set to 1 second).
|
static int |
DEFAULT_PIXEL_THREASHOLD
Default pixel difference intensity threshold (set to 25).
|
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.
|
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.
|
int |
getInterval() |
double |
getMotionArea()
Get percentage fraction of image covered by motion.
|
Point |
getMotionCog()
Get motion center of gravity.
|
WebcamMotionListener[] |
getMotionListeners() |
Webcam |
getWebcam()
Get attached webcam object.
|
boolean |
isMotion() |
boolean |
removeMotionListener(WebcamMotionListener l)
Removes motion listener.
|
void |
setAreaThreshold(double threshold)
Set percentage fraction of detected motion area threshold above which it
is classified as "moved".
|
void |
setInertia(int inertia)
Set motion inertia (time when motion is valid).
|
void |
setInterval(int interval)
Motion check interval in milliseconds.
|
void |
setPixelThreshold(int threshold)
Set pixel intensity difference threshold above which pixel is classified
as "moved".
|
void |
start() |
void |
stop() |
public static final int DEFAULT_PIXEL_THREASHOLD
public static final int DEFAULT_INTERVAL
public static final double DEFAULT_AREA_THREASHOLD
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 motioninertia
- for how long motion is valid (seconds)interval
- the check intervalpublic WebcamMotionDetector(Webcam webcam, int pixelThreshold, double areaThreshold)
webcam
- web camera instancepixelThreshold
- intensity threshold (0 - 255)areaThreshol
- percentage threshold of image covered by motionpublic 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()
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 thresholdDEFAULT_PIXEL_THREASHOLD
public void setAreaThreshold(double threshold)
threshold
- the percentage fraction of image areaDEFAULT_AREA_THREASHOLD
public void setInertia(int inertia)
clearInertia()
method must be used.inertia
- the motion inertia time in millisecondsclearInertia()
public void clearInertia()
public boolean isMotion()
public double getMotionArea()
public Point getMotionCog()
Copyright © 2012-2013 Bartosz Firyn (SarXos). All Rights Reserved.