Bartosz Firyn (SarXos)

com.github.sarxos.webcam
Class WebcamMotionDetector

java.lang.Object
  extended by com.github.sarxos.webcam.WebcamMotionDetector

public class WebcamMotionDetector
extends Object

Webcam motion detector.

Author:
Bartosz Firyn (SarXos)

Field Summary
static int DEFAULT_THREASHOLD
           
 
Constructor Summary
WebcamMotionDetector(Webcam webcam)
          Create motion detector with default parameters - threshold = 25, inertia = 0.
WebcamMotionDetector(Webcam webcam, int threshold)
          Create motion detector with default parameter inertia = 0.
WebcamMotionDetector(Webcam webcam, int threshold, int inertia)
          Create motion detector.
 
Method Summary
 boolean addMotionListener(WebcamMotionListener l)
          Add motion listener.
 int getInterval()
           
 WebcamMotionListener[] getMotionListeners()
           
 int getMotionStrength()
           
 Webcam getWebcam()
           
 boolean isMotion()
           
 boolean removeMotionListener(WebcamMotionListener l)
          Removes motion listener.
 void setCheckInterval(int interval)
          Motion check interval in milliseconds.
 void setInertia(int inertia)
          How long motion should be valid.
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_THREASHOLD

public static final int DEFAULT_THREASHOLD
See Also:
Constant Field Values
Constructor Detail

WebcamMotionDetector

public WebcamMotionDetector(Webcam webcam,
                            int threshold,
                            int inertia)
Create motion detector. Will open webcam if it is closed.

Parameters:
webcam - web camera instance
threshold - intensity threshold (0 - 255)
inertia - for how long motion is valid (seconds)

WebcamMotionDetector

public WebcamMotionDetector(Webcam webcam,
                            int threshold)
Create motion detector with default parameter inertia = 0.

Parameters:
webcam - web camera instance
threshold - intensity threshold (0 - 255)

WebcamMotionDetector

public WebcamMotionDetector(Webcam webcam)
Create motion detector with default parameters - threshold = 25, inertia = 0.

Parameters:
webcam - web camera instance
Method Detail

start

public void start()

stop

public void stop()

addMotionListener

public boolean addMotionListener(WebcamMotionListener l)
Add motion listener.

Parameters:
l - listener to add
Returns:
true if listeners list has been changed, false otherwise

getMotionListeners

public WebcamMotionListener[] getMotionListeners()
Returns:
All motion listeners as array

removeMotionListener

public boolean removeMotionListener(WebcamMotionListener l)
Removes motion listener.

Parameters:
l - motion listener to remove
Returns:
true if listener was available on the list, false otherwise

getInterval

public int getInterval()
Returns:
Motion check interval in milliseconds

setCheckInterval

public void setCheckInterval(int interval)
Motion check interval in milliseconds.

Parameters:
interval - the new motion check interval (ms)

getWebcam

public Webcam getWebcam()

isMotion

public boolean isMotion()

getMotionStrength

public int getMotionStrength()

setInertia

public void setInertia(int inertia)
How long motion should be valid. Value is in milliseconds. If less than 0, then inertia is calculated as 0.5 interval value, so motion is invalid at the next detector tick.

Parameters:
inertia - the new inertia value (milliseconds)

Bartosz Firyn (SarXos)

Copyright © 2012-2013 Bartosz Firyn (SarXos). All Rights Reserved.