maslab.camera
Class Camera

java.lang.Object
  extended by maslab.camera.Camera

public class Camera
extends java.lang.Object


Field Summary
static int WB_AUTO
           
static int WB_FLOURESCENT
           
static int WB_INDOOR
           
static int WB_MANUAL
           
static int WB_OUTDOOR
           
 
Constructor Summary
Camera()
          Open a camera, searching /dev/videoX and /dev/video.
Camera(java.lang.String devname)
          Open a camera.
 
Method Summary
 java.awt.image.BufferedImage capture()
          Capture a single frame, allocating a new buffer.
 java.awt.image.BufferedImage capture(java.awt.image.BufferedImage image)
          Capture a single frame.
static java.awt.image.BufferedImage channelSelect(java.awt.image.BufferedImage image, int channel)
           
 void close()
          Close the camera.
 java.awt.image.BufferedImage createImage()
          Create a BufferedImage with the correct format/bitdepth for future capture operations.
 boolean getBacklightCompensation()
          Get BacklightCompensation mode.
 int getContour()
          Get contour filter value.
 boolean getFlicker()
          Get Flicker Compensation mode.
 int getFps()
          The current target fps setting of the camera.
 int getGain()
          Get gain value.
 int getHeight()
          The current height setting of the camera.
 int getLedOff()
           
 int getLedOn()
           
 int getNoiseReduction()
          Get Noise Reduction mode.
 int getQuality()
          Get the current quality level.
 int getWhiteBalanceBlue()
          If white balance mode is manual, returns the blue gain.
 int getWhiteBalanceMode()
          Determine the current white balance mode (e.g., WB_INDOOR).
 int getWhiteBalanceRed()
          If white balance mode is manual, returns the red gain.
 int getWidth()
          The current width setting of the camera.
static java.awt.image.BufferedImage rgbToHsv(java.awt.image.BufferedImage image)
          Converts the image into RGB.
static java.awt.image.BufferedImage rgbToRgv(java.awt.image.BufferedImage image)
          Converts the image into RGV.
 void setBacklightCompensation(boolean value)
          Set Backlight Compensation mode.
 void setCaptureSettings(int width, int height, int fps)
          Request a new size from the camera.
 void setContour(int value)
          Set Contour filter.
 void setFlicker(boolean value)
          Set Flicker Compensation mode.
 void setGain(int value)
          Set gain control.
 void setLed(int onTime, int offTime)
          Set the LED's blinking rate.
 void setNoiseReduction(int value)
          Set Noise Reduction mode.
 void setQuality(int value)
          Set quality (compression) level.
 void setShutter(int value)
          Set shutter speed.
 void setWhiteBalanceManual(int red, int blue)
          Sets the camera to manual white balance, using the provided red and blue gains.
 void setWhiteBalanceMode(int mode)
          Set the current white balance mode, e.g., WB_INDOOR.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WB_INDOOR

public static final int WB_INDOOR
See Also:
Constant Field Values

WB_OUTDOOR

public static final int WB_OUTDOOR
See Also:
Constant Field Values

WB_FLOURESCENT

public static final int WB_FLOURESCENT
See Also:
Constant Field Values

WB_MANUAL

public static final int WB_MANUAL
See Also:
Constant Field Values

WB_AUTO

public static final int WB_AUTO
See Also:
Constant Field Values
Constructor Detail

Camera

public Camera()
       throws java.io.IOException
Open a camera, searching /dev/videoX and /dev/video.

Throws:
java.io.IOException

Camera

public Camera(java.lang.String devname)
       throws java.io.IOException
Open a camera.

Parameters:
devname - The path to the device to open.
Throws:
java.io.IOException
Method Detail

close

public void close()
Close the camera. Methods should not be called on this object after close.


createImage

public java.awt.image.BufferedImage createImage()
Create a BufferedImage with the correct format/bitdepth for future capture operations. A new BufferedImage must be created whenever camera resolution/bit-depth changes.


capture

public java.awt.image.BufferedImage capture()
Capture a single frame, allocating a new buffer.


capture

public java.awt.image.BufferedImage capture(java.awt.image.BufferedImage image)
Capture a single frame.

Parameters:
image - The image to be overwritten with the current camera frame.

setCaptureSettings

public void setCaptureSettings(int width,
                               int height,
                               int fps)
Request a new size from the camera.

Parameters:
width - Width, in pixels
height - Height, in pixels.

getWidth

public int getWidth()
The current width setting of the camera.


getHeight

public int getHeight()
The current height setting of the camera.


getFps

public int getFps()
The current target fps setting of the camera.


setWhiteBalanceMode

public void setWhiteBalanceMode(int mode)
Set the current white balance mode, e.g., WB_INDOOR. For computer vision applications, using automatic white balance can be very undesirable.


getWhiteBalanceMode

public int getWhiteBalanceMode()
Determine the current white balance mode (e.g., WB_INDOOR).


getWhiteBalanceRed

public int getWhiteBalanceRed()
If white balance mode is manual, returns the red gain.


getWhiteBalanceBlue

public int getWhiteBalanceBlue()
If white balance mode is manual, returns the blue gain.


setWhiteBalanceManual

public void setWhiteBalanceManual(int red,
                                  int blue)
Sets the camera to manual white balance, using the provided red and blue gains.

Parameters:
red - [0,65535] Red channel gain
blue - [0,65535] Blue channel gain.

setLed

public void setLed(int onTime,
                   int offTime)
Set the LED's blinking rate. The resolution is internally only about 100ms. Set (100,0) for on, (0,100) for off.

Parameters:
onTime - [0-25000] (ms)
offTime - [range unknown] (ms)

getLedOn

public int getLedOn()

getLedOff

public int getLedOff()

setQuality

public void setQuality(int value)
Set quality (compression) level.

Parameters:
value - [0-3]. 0=no compression, 3=high compression.

getQuality

public int getQuality()
Get the current quality level.


setContour

public void setContour(int value)
Set Contour filter.

Parameters:
value - [0-65535]. 0=blur, 65535=sharpen. -1 means auto.

getContour

public int getContour()
Get contour filter value.


setBacklightCompensation

public void setBacklightCompensation(boolean value)
Set Backlight Compensation mode. Only operates if auto gain is on.

Parameters:
value - Enabled if true.

getBacklightCompensation

public boolean getBacklightCompensation()
Get BacklightCompensation mode.


setFlicker

public void setFlicker(boolean value)
Set Flicker Compensation mode.

Parameters:
value - Enabled if true.

getFlicker

public boolean getFlicker()
Get Flicker Compensation mode.


setNoiseReduction

public void setNoiseReduction(int value)
Set Noise Reduction mode.

Parameters:
value - [0,3]. 0=off, 3=lots of filtering.

getNoiseReduction

public int getNoiseReduction()
Get Noise Reduction mode.


setGain

public void setGain(int value)
Set gain control.

Parameters:
value - [0,65535]. 0=low gain, 65535=max gain. gain<0 means auto.

getGain

public int getGain()
Get gain value.


setShutter

public void setShutter(int value)
Set shutter speed. 0=short shutter, 65535=maximum shutter, but scale is nonlinear. speed<0 means auto.


rgbToHsv

public static java.awt.image.BufferedImage rgbToHsv(java.awt.image.BufferedImage image)
Converts the image into RGB. The modification is done in-place, if the image buffer type is INT_RGB, otherwise, a new image is allocated. The HSV image is returned.


rgbToRgv

public static java.awt.image.BufferedImage rgbToRgv(java.awt.image.BufferedImage image)
Converts the image into RGV. The modification is done in-place, if the image buffer type is INT_RGB, otherwise, a new image is allocated. The HSV image is returned.


channelSelect

public static java.awt.image.BufferedImage channelSelect(java.awt.image.BufferedImage image,
                                                         int channel)