001 package com.github.sarxos.webcam;
002
003 import java.awt.Dimension;
004 import java.awt.image.BufferedImage;
005 import java.nio.ByteBuffer;
006
007
008 /**
009 * Webcam device abstraction.
010 *
011 * @author Bartosz Firyn (SarXos)
012 */
013 public interface WebcamDevice {
014
015 /**
016 * This interface should be implemented by all webcam devices supporting
017 * possibility to access raw bytes or direct bytes buffer from native webcam
018 * device.
019 *
020 * @author Bartosz Firyn (SarXos)
021 */
022 public static interface BufferAccess {
023
024 /**
025 * Get image in form of raw bytes. Do <b>not</b> use this buffer to set
026 * bytes value, it should be used only for read purpose!
027 *
028 * @return Bytes buffer
029 */
030 ByteBuffer getImageBytes();
031
032 }
033
034 public static interface FPSSource {
035
036 /**
037 * Get current device FPS.
038 *
039 * @return FPS
040 */
041 double getFPS();
042
043 }
044
045 /**
046 * Get device name.
047 *
048 * @return Device name
049 */
050 String getName();
051
052 /**
053 * Get the list of all possible image resolutions.
054 *
055 * @return Possible resolutions
056 */
057 Dimension[] getResolutions();
058
059 /**
060 * Get currently set image size.
061 *
062 * @return The size which is currently set
063 */
064 Dimension getResolution();
065
066 /**
067 * Set new expected image size.
068 *
069 * @param size the size to be set
070 */
071 void setResolution(Dimension size);
072
073 /**
074 * Fetch image from underlying camera.
075 *
076 * @return Image
077 */
078 BufferedImage getImage();
079
080 /**
081 * Open device, it can be closed any time.
082 */
083 void open();
084
085 /**
086 * Close device, however it can be open again.
087 */
088 void close();
089
090 /**
091 * Dispose device. After device is disposed it cannot be open again.
092 */
093 void dispose();
094
095 /**
096 * Is webcam device open?
097 *
098 * @return True if webcam device is open, false otherwise
099 */
100 boolean isOpen();
101 }