edu.berkeley.guir.ptk.input
Class CameraInput

java.lang.Object
  extended byedu.berkeley.guir.ptk.PTK
      extended byedu.berkeley.guir.ptk.input.InputSource
          extended byedu.berkeley.guir.ptk.input.CameraInput
All Implemented Interfaces:
java.lang.Runnable

public class CameraInput
extends InputSource

Gets images from a webcam or other digital camera and dispatches each image in an event. Images are a PlanarImage stored in a DataObject. Note: you may want to increase the amount of time between events in order to reduce the amount of processing (especially if using any of the image abstractors). To do so, call CameraInput.setTimeBetweenEvents(long).

Author:
tmatthew

Field Summary
protected  edu.berkeley.guir.papier_mache.input.CameraImageInput camera
           
protected  java.lang.Object image
           
static java.lang.String MY_ID
           
protected static java.lang.String SHORT_STRING
           
 
Fields inherited from class edu.berkeley.guir.ptk.input.InputSource
history, mds, my_id, my_ip, time_between_events
 
Fields inherited from class edu.berkeley.guir.ptk.PTK
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG
 
Constructor Summary
CameraInput()
          Constructors for non-distributed applications.
CameraInput(Abstractor abs)
          Constructors for non-distributed applications that takes an Abstractor.
CameraInput(Abstractor[] abs)
          Constructor for non-distributed applications that takes an array of Abstractors.
CameraInput(java.lang.String my_ip)
          Constructor for distributed applications.
CameraInput(java.lang.String my_ip, Abstractor abs)
          Constructor for distributed applications that takes an Abstractor.
CameraInput(java.lang.String my_ip, Abstractor[] abs)
          Constructor for distributed applications that takes an array of Abstractors.
 
Method Summary
 javax.media.jai.PlanarImage captureFrame()
          Used for evaluation - environment sampling - to capture a single frame and returns it, without packaging it in an event or dispatching it to the server.
static void main(java.lang.String[] argv)
          Starts this Input with the IP address CameraConstants.DEFAULT_INPUT_IP.
 Events newInput()
          Gets the new input from a global variable that is set by the ImageCaptureThread.fireDataSampleEvent method as quickly as it can get new frames from the camera.
 
Methods inherited from class edu.berkeley.guir.ptk.input.InputSource
addMetadata, addMetadataItem, addMyMetadataToEvent, dispatchEvent, finalize, getAbstractThenSendInputEvent, getMetadata, getMetadataItemsAsArray, getThenSendInputEvent, register, run, setMetadata, setTimeBetweenEvents, startInput
 
Methods inherited from class edu.berkeley.guir.ptk.PTK
getMAX, getMED, getMIN, getNO, printDebug, printDebug, printError
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MY_ID

public static final java.lang.String MY_ID
See Also:
Constant Field Values

SHORT_STRING

protected static final java.lang.String SHORT_STRING
See Also:
Constant Field Values

image

protected java.lang.Object image

camera

protected edu.berkeley.guir.papier_mache.input.CameraImageInput camera
Constructor Detail

CameraInput

public CameraInput()
Constructors for non-distributed applications. An input that uses this constructor cannot be part of an application on another machine.


CameraInput

public CameraInput(Abstractor abs)
Constructors for non-distributed applications that takes an Abstractor. An input that uses this constructor (1) cannot be part of an application on another machine and (2) will have abstraction done on the input side.

Parameters:
abs -

CameraInput

public CameraInput(Abstractor[] abs)
Constructor for non-distributed applications that takes an array of Abstractors. An input that uses this constructor (1) cannot be part of an application on another machine and (2) will have abstraction done on the input side.

Parameters:
abs -

CameraInput

public CameraInput(java.lang.String my_ip)
Constructor for distributed applications. An input that uses this constructor can be part of an application on another machine.


CameraInput

public CameraInput(java.lang.String my_ip,
                   Abstractor abs)
Constructor for distributed applications that takes an Abstractor. An input that uses this constructor can be part of an application on another machine.


CameraInput

public CameraInput(java.lang.String my_ip,
                   Abstractor[] abs)
Constructor for distributed applications that takes an array of Abstractors. An input that uses this constructor can be part of an application on another machine.

Method Detail

newInput

public Events newInput()
Gets the new input from a global variable that is set by the ImageCaptureThread.fireDataSampleEvent method as quickly as it can get new frames from the camera.

Specified by:
newInput in class InputSource
Returns:
an Events with the new camera image, or null of no camera image has been taken (often this is the case upon camera start-up).

captureFrame

public javax.media.jai.PlanarImage captureFrame()
Used for evaluation - environment sampling - to capture a single frame and returns it, without packaging it in an event or dispatching it to the server. This method is called by EnvironmentSampling.saveImage().


main

public static void main(java.lang.String[] argv)
Starts this Input with the IP address CameraConstants.DEFAULT_INPUT_IP. Can instead take one command line parameter: (1) IP address where this Input is running.

Parameters:
argv - IP address where this Input is running, as a String.