com.github.sarxos.webcam.WebcamMotionEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webcam-capture Show documentation
Show all versions of webcam-capture Show documentation
This library allows you to use your PC webcam, IP or network cameras directly from Java. It's compatible with most operating systems (Windows, Linux, MacOS).
package com.github.sarxos.webcam;
import java.awt.Point;
import java.util.EventObject;
/**
* Webcam detected motion event.
*
* @author Bartosz Firyn (SarXos)
*/
public class WebcamMotionEvent extends EventObject {
private static final long serialVersionUID = -7245768099221999443L;
private final double strength;
private final Point cog;
/**
* Create detected motion event.
*
* @param detector
* @param strength
* @param cog center of motion gravity
*/
public WebcamMotionEvent(WebcamMotionDetector detector, double strength, Point cog) {
super(detector);
this.strength = strength;
this.cog = cog;
}
/**
* Get percentage fraction of image covered by motion. 0 is no motion on image, and 100 is full
* image covered by motion.
*
* @return Motion area
*/
public double getArea() {
return strength;
}
public Point getCog() {
return cog;
}
}