Bartosz Firyn (SarXos)

com.github.sarxos.webcam
Class WebcamUpdater

java.lang.Object
  extended by com.github.sarxos.webcam.WebcamUpdater
All Implemented Interfaces:
Runnable, ThreadFactory

public class WebcamUpdater
extends Object
implements Runnable, ThreadFactory

The goal of webcam updater class is to update image in parallel, so all calls to fetch image invoked on webcam instance will be non-blocking (will return immediately).

Author:
Bartosz Firyn (sarxos)

Method Summary
 double getFPS()
          Return current FPS number.
 BufferedImage getImage()
          Return currently available image.
 Thread newThread(Runnable r)
           
 void run()
           
 void start()
          Start updater.
 void stop()
          Stop updater.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

start

public void start()
Start updater.


stop

public void stop()
Stop updater.


run

public void run()
Specified by:
run in interface Runnable

getImage

public BufferedImage getImage()
Return currently available image. This method will return immediately while it was been called after camera has been open. In case when there are parallel threads running and there is a possibility to call this method in the opening time, or before camera has been open at all, this method will block until webcam return first image. Maximum blocking time will be 10 seconds, after this time method will return null.

Returns:

getFPS

public double getFPS()
Return current FPS number. It is calculated in real-time on the base of how often camera serve new image.

Returns:
FPS number

newThread

public Thread newThread(Runnable r)
Specified by:
newThread in interface ThreadFactory

Bartosz Firyn (SarXos)

Copyright © 2012-2013 Bartosz Firyn (SarXos). All Rights Reserved.