Modifier and Type | Method and Description |
---|---|
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 WebcamDiscoveryService |
getDiscoveryServiceRef()
Return discovery service without creating it if not exists.
|
static WebcamDriver |
getDriver()
Return webcam driver.
|
double |
getFPS() |
BufferedImage |
getImage()
Capture image from webcam and return it.
|
ByteBuffer |
getImageBytes()
Get RAW image ByteBuffer.
|
void |
getImageBytes(ByteBuffer target)
Get RAW image ByteBuffer.
|
WebcamImageTransformer |
getImageTransformer()
Return image transformer.
|
WebcamLock |
getLock()
Return webcam lock.
|
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 |
isImageNew() |
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 wd)
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 |
setImageTransformer(WebcamImageTransformer transformer)
Set image transformer.
|
void |
setViewSize(Dimension size)
Set new view size.
|
static void |
shutdown() |
String |
toString() |
public boolean open()
WebcamException
- when something went wrongopen(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.async
- true for non-blocking mode, false for blockingWebcamException
- when something went wrongpublic boolean close()
public WebcamDevice getDevice()
WebcamDefaultDevice
is
returned when no external driver is used.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 boolean isImageNew()
public double getFPS()
public ByteBuffer getImageBytes()
public void getImageBytes(ByteBuffer target)
target
- the target ByteBuffer
object to copy data intopublic 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 discoveredTimeoutException
- when timeout occursWebcamException
- when something is wrongIllegalArgumentException
- when timeout is negativegetWebcams(long, TimeUnit)
public static List<Webcam> getWebcams(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException
timeout
- the devices discovery timeouttunit
- the time unitTimeoutException
- when timeout has been exceededWebcamException
- when something is wrongIllegalArgumentException
- when timeout is negative or tunit nullpublic 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 exceededWebcamException
- if something is really wrongIllegalArgumentException
- when timeout is negativegetWebcams(long)
public static Webcam getDefault(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException
timeout
- the webcam discovery timeout (1 minute by default)tunit
- the time unitTimeoutException
- when discovery timeout has been exceededWebcamException
- if something is really wrongIllegalArgumentException
- when timeout is negative or tunit nullgetWebcams(long, TimeUnit)
public String getName()
public boolean addWebcamListener(WebcamListener l)
l
- the listener to be addedIllegalArgumentException
- when argument is nullpublic WebcamListener[] getWebcamListeners()
public int getWebcamListenersCount()
public boolean removeWebcamListener(WebcamListener l)
l
- the listener to be removedpublic static WebcamDriver getDriver()
public static void setDriver(WebcamDriver wd)
wd
- 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.driverClass
- new video driver class to useIllegalArgumentException
- when argument is nullpublic static void resetDriver()
public static void registerDriver(Class<? extends WebcamDriver> clazz)
clazz
- webcam video driver classIllegalArgumentException
- when argument is nullpublic static void registerDriver(String clazzName)
clazzName
- webcam video driver class nameIllegalArgumentException
- when argument is nullpublic 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 addedIllegalArgumentException
- when argument is nullpublic static WebcamDiscoveryListener[] getDiscoveryListeners()
public static boolean removeDiscoveryListener(WebcamDiscoveryListener l)
l
- the listener to be removedpublic static WebcamDiscoveryService getDiscoveryService()
public static WebcamDiscoveryService getDiscoveryServiceRef()
public WebcamImageTransformer getImageTransformer()
public void setImageTransformer(WebcamImageTransformer transformer)
transformer
- the transformer to be setpublic WebcamLock getLock()
public static void shutdown()
Copyright © 2012-2014 Bartosz Firyn (SarXos). All Rights Reserved.