All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sarxos.webcam.WebcamEvent Maven / Gradle / Ivy

Go to download

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).

There is a newer version: 0.3.12
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy