com.github.sarxos.webcam.WebcamEvent 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.image.BufferedImage;
import java.util.EventObject;
/**
* Webcam event.
*
* @author Bartosz Firyn (SarXos)
*/
public class WebcamEvent extends EventObject {
private static final long serialVersionUID = 1L;
/**
* Image acquired from webcam
*/
private BufferedImage image = null;
/**
* Event type.
*/
private WebcamEventType type = null;
/**
* Webcam event.
*
* @param type the event type
* @param w the webcam object
*/
public WebcamEvent(WebcamEventType type, Webcam w) {
this(type, w, null);
}
/**
* Webcam event.
*
* @param type the event type
* @param w the webcam object
* @param image the image acquired from webcam
*/
public WebcamEvent(WebcamEventType type, Webcam w, BufferedImage image) {
super(w);
this.type = type;
this.image = image;
}
@Override
public Webcam getSource() {
return (Webcam) super.getSource();
}
/**
* Return image acquired by webcam. This method will return not-null object
* only in case new image acquisition event. For all other events, it
* will simply return null.
*
* @return Acquired image
*/
public BufferedImage getImage() {
return image;
}
/**
* Return event type.
*
* @return Event type
* @see WebcamEventType
*/
public WebcamEventType getType() {
return type;
}
}