|
Bartosz Firyn (SarXos) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.github.sarxos.webcam.Webcam
public class Webcam
Webcam class. It wraps webcam device obtained from webcam driver.
Method Summary | |
---|---|
static boolean |
addDiscoveryListener(WebcamDiscoveryListener l)
Add new webcam discovery listener. |
boolean |
addWebcamListener(WebcamListener l)
Add webcam listener. |
boolean |
close()
Close the webcam. |
Dimension[] |
getCustomViewSizes()
|
static Webcam |
getDefault()
Will discover and return first webcam available in the system. |
static Webcam |
getDefault(long timeout)
Will discover and return first webcam available in the system. |
static Webcam |
getDefault(long timeout,
TimeUnit tunit)
Will discover and return first webcam available in the system. |
WebcamDevice |
getDevice()
Return underlying webcam device. |
static WebcamDiscoveryListener[] |
getDiscoveryListeners()
|
static WebcamDiscoveryService |
getDiscoveryService()
Return discovery service. |
static WebcamDriver |
getDriver()
Return webcam driver. |
BufferedImage |
getImage()
Capture image from webcam and return it. |
ByteBuffer |
getImageBytes()
Get RAW image ByteBuffer. |
String |
getName()
Get webcam name (device name). |
Dimension |
getViewSize()
Get current webcam resolution in pixels. |
Dimension[] |
getViewSizes()
Return list of supported view sizes. |
WebcamListener[] |
getWebcamListeners()
|
int |
getWebcamListenersCount()
|
static List<Webcam> |
getWebcams()
Get list of webcams to use. |
static List<Webcam> |
getWebcams(long timeout)
Get list of webcams to use. |
static List<Webcam> |
getWebcams(long timeout,
TimeUnit tunit)
Get list of webcams to use. |
static boolean |
isAutoOpenMode()
Is auto open mode enabled. |
static boolean |
isHandleTermSignal()
Is TERM signal handler enabled. |
boolean |
isOpen()
Is webcam open? |
boolean |
open()
Open the webcam in blocking (synchronous) mode. |
boolean |
open(boolean async)
Open the webcam in either blocking (synchronous) or non-blocking (asynchronous) mode.The difference between those two modes lies in the image acquisition mechanism. In blocking mode, when user calls getImage() method, device is
being queried for new image buffer and user have to wait for it to be
available.In non-blocking mode, there is a special thread running in the background which constantly fetch new images and cache them internally for further use. |
static void |
registerDriver(Class<? extends WebcamDriver> clazz)
Register new webcam video driver. |
static void |
registerDriver(String clazzName)
Register new webcam video driver. |
static boolean |
removeDiscoveryListener(WebcamDiscoveryListener l)
Remove discovery listener |
boolean |
removeWebcamListener(WebcamListener l)
Removes webcam listener. |
static void |
resetDriver()
Reset webcam driver. This method is not thread-safe! |
static void |
setAutoOpenMode(boolean on)
Switch all webcams to auto open mode. |
void |
setCustomViewSizes(Dimension[] sizes)
Set custom resolution. |
static void |
setDriver(Class<? extends WebcamDriver> driverClass)
Set new video driver class to be used by webcam. |
static void |
setDriver(WebcamDriver driver)
Set new video driver to be used by webcam. This method is not thread-safe! |
static void |
setHandleTermSignal(boolean on)
CAUTION!!! This is experimental feature to be used mostly in in development phase. |
void |
setViewSize(Dimension size)
Set new view size. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public boolean open()
open(boolean)
public boolean open(boolean async)
getImage()
method, device is
being queried for new image buffer and user have to wait for it to be
available.#isImageNew()
method to distinguish if
returned image is not the same as the previous one.
asynchronous
- true for non-blocking mode, false for blockingpublic boolean close()
public boolean isOpen()
public Dimension getViewSize()
public Dimension[] getViewSizes()
public void setCustomViewSizes(Dimension[] sizes)
sizes
- the array of custom resolutions to be supported by webcampublic Dimension[] getCustomViewSizes()
public void setViewSize(Dimension size)
size
- the new view size to be setsetCustomViewSizes(Dimension[])
,
getViewSizes()
public BufferedImage getImage()
public ByteBuffer getImageBytes()
public static List<Webcam> getWebcams() throws WebcamException
WebcamException
- when something is wronggetWebcams(long, TimeUnit)
public static List<Webcam> getWebcams(long timeout) throws TimeoutException, WebcamException
timeout
- the time to wait for webcam devices to be discovered
WebcamException
- when something is wrong
TimeoutException
getWebcams(long, TimeUnit)
public static List<Webcam> getWebcams(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException
timeout
- the devices discovery timeouttunit
- the time unit
TimeoutException
- when timeout has been exceeded
WebcamException
- when something is wrongpublic static Webcam getDefault() throws WebcamException
WebcamException
- if something is really wronggetWebcams()
public static Webcam getDefault(long timeout) throws TimeoutException, WebcamException
timeout
- the webcam discovery timeout (1 minute by default)
TimeoutException
- when discovery timeout has been exceeded
WebcamException
- if something is really wronggetWebcams(long)
public static Webcam getDefault(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException
timeout
- the webcam discovery timeout (1 minute by default)tunit
- the time unit
TimeoutException
- when discovery timeout has been exceeded
WebcamException
- if something is really wronggetWebcams(long, TimeUnit)
public String getName()
public String toString()
toString
in class Object
public boolean addWebcamListener(WebcamListener l)
l
- the listener to be added
IllegalArgumentException
- when argument is nullpublic WebcamListener[] getWebcamListeners()
public int getWebcamListenersCount()
public boolean removeWebcamListener(WebcamListener l)
l
- the listener to be removed
public static WebcamDriver getDriver()
public static void setDriver(WebcamDriver driver)
driver
- new webcam driver to be used (e.g. LtiCivil, JFM, FMJ, QTJ)
IllegalArgumentException
- when argument is nullpublic static void setDriver(Class<? extends WebcamDriver> driverClass)
WebcamDriver
interface and should have
public default constructor, so instance can be created by reflection.
driver
- new video driver class to use
IllegalArgumentException
- when argument is nullpublic static void resetDriver()
public static void registerDriver(Class<? extends WebcamDriver> clazz)
clazz
- webcam video driver class
IllegalArgumentException
- when argument is nullpublic static void registerDriver(String clazzName)
clazzName
- webcam video driver class name
IllegalArgumentException
- when argument is nullpublic WebcamDevice getDevice()
WebcamDefaultDevice
is returned when no external driver is used.
public static void setHandleTermSignal(boolean on)
on
- signal handling will be enabled if true, disabled otherwisepublic static boolean isHandleTermSignal()
public static void setAutoOpenMode(boolean on)
on
- true to enable, false to disablepublic static boolean isAutoOpenMode()
public static boolean addDiscoveryListener(WebcamDiscoveryListener l)
l
- the listener to be added
IllegalArgumentException
- when argument is nullpublic static WebcamDiscoveryListener[] getDiscoveryListeners()
public static boolean removeDiscoveryListener(WebcamDiscoveryListener l)
l
- the listener to be removed
public static WebcamDiscoveryService getDiscoveryService()
|
Bartosz Firyn (SarXos) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |