icommand.vision
Class Vision

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by icommand.vision.Vision
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.media.ControllerListener

public class Vision
extends java.awt.Frame
implements javax.media.ControllerListener

Java version of Vision Command.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Vision(java.lang.String title)
          Create the viewer frame with a title.
 
Method Summary
static void addColorListener(int region, ColorListener cl, int color)
          Add a Color Listener for the region
static void addLightListener(int region, LightListener ll)
          Add a LightSensor Listener for the region
static void addMotionListener(int region, MotionListener ml)
          Add a Motion Listener for the region
 void addNotify()
           
static void addRectRegion(int region, int x, int y, int width, int height)
          Add a rectangular region
 void controllerUpdate(javax.media.ControllerEvent evt)
          Controller Listener.
static void flipHorizontal(boolean flip)
          Flip the image in the image viewer horizontally
static int getAvgBlue(int region)
          Get the average blue value for the region
static int getAvgGreen(int region)
          Get the average green value for the region
static int getAvgRed(int region)
          Get the average red value for the region
static int getAvgRGB(int region)
          Get the average RGB value for the region
static java.awt.Frame getFrame()
          Get the viewer frame.
static Region[] getRegions()
          Get the array of regions
static boolean isRecording()
          Test is recording is in progress
 boolean open(javax.media.protocol.DataSource tds)
          Given a datasource, create a processor and use that processor as a player to playback the media.
static void playSound(java.lang.String fileName)
          Play an audio file
static void setFrameRate(float rate)
          Set the frame rate
static void setImageSize(int width, int height)
          Set the size of the video viewer image
static void snapshot(java.lang.String filename)
          Take a snapshot
static void startRecorder(java.lang.String fileName, int millis)
          Start the video recorder
static void startViewer(java.lang.String title)
          Start the video viewer frame
static void stopRecording()
           
static void stopViewer()
          Close Video viewer
static void writeImage(java.lang.String fn, byte[] data, int width, int height)
          Write to fn file the data using the width, height variables.
 
Methods inherited from class java.awt.Frame
finalize, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

Vision

public Vision(java.lang.String title)
Create the viewer frame with a title.

Parameters:
title - the title for the viewer
Method Detail

getFrame

public static java.awt.Frame getFrame()
Get the viewer frame. Allows extra controls to be added.

Returns:
the frame

open

public boolean open(javax.media.protocol.DataSource tds)
Given a datasource, create a processor and use that processor as a player to playback the media. During the processor's Configured state, the FlipEffect, MotionDetectionEffect ColorEffect and RegionEffect are inserted into the video track.


stopViewer

public static void stopViewer()
Close Video viewer


addNotify

public void addNotify()
Overrides:
addNotify in class java.awt.Frame

controllerUpdate

public void controllerUpdate(javax.media.ControllerEvent evt)
Controller Listener.

Specified by:
controllerUpdate in interface javax.media.ControllerListener

startViewer

public static void startViewer(java.lang.String title)
Start the video viewer frame


playSound

public static void playSound(java.lang.String fileName)
Play an audio file

Parameters:
fileName - the audio file to play

addRectRegion

public static void addRectRegion(int region,
                                 int x,
                                 int y,
                                 int width,
                                 int height)
Add a rectangular region

Parameters:
region - the region number
x - the x co-ordinate of the region bottom left corner
y - the y co-ordinate of the region bottom left corner
width - the width of the region
height - the height of the region

getRegions

public static Region[] getRegions()
Get the array of regions

Returns:
the array of regions

setFrameRate

public static void setFrameRate(float rate)
Set the frame rate

Parameters:
rate - the required frame rate

setImageSize

public static void setImageSize(int width,
                                int height)
Set the size of the video viewer image

Parameters:
width - the required image width
height - the required image height

addMotionListener

public static void addMotionListener(int region,
                                     MotionListener ml)
Add a Motion Listener for the region

Parameters:
region - the region
ml - the Motion Listener

addColorListener

public static void addColorListener(int region,
                                    ColorListener cl,
                                    int color)
Add a Color Listener for the region

Parameters:
region - the region
cl - the Color Listener
color - the color to listen for

addLightListener

public static void addLightListener(int region,
                                    LightListener ll)
Add a LightSensor Listener for the region

Parameters:
region - the region
ll - the LightSensor Listener

snapshot

public static void snapshot(java.lang.String filename)
Take a snapshot

Parameters:
filename - the JPG file to write the snapshop to

writeImage

public static void writeImage(java.lang.String fn,
                              byte[] data,
                              int width,
                              int height)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
Write to fn file the data using the width, height variables. Data is assumed to be 8bit RGB. A JPEG format file is written.

Parameters:
fn - the filename
data - the data to write
width - the width of the image
height - the height of the image
Throws:
java.io.FileNotFoundException - if the directory/image specified is wrong
java.io.IOException - if there are problems reading the file.

startRecorder

public static void startRecorder(java.lang.String fileName,
                                 int millis)
Start the video recorder

Parameters:
fileName - the file to write the video to
millis - the number of milliseconds to record for. 0 means record until stopRecoder() is called.

isRecording

public static boolean isRecording()
Test is recording is in progress

Returns:
true if recoding, else false

stopRecording

public static void stopRecording()

getAvgRed

public static int getAvgRed(int region)
Get the average red value for the region

Parameters:
region - the region
Returns:
the average red value

getAvgGreen

public static int getAvgGreen(int region)
Get the average green value for the region

Parameters:
region - the region
Returns:
the average green value

getAvgBlue

public static int getAvgBlue(int region)
Get the average blue value for the region

Parameters:
region - the region
Returns:
the average blue value

getAvgRGB

public static int getAvgRGB(int region)
Get the average RGB value for the region

Parameters:
region - the region
Returns:
the average RGB value

flipHorizontal

public static void flipHorizontal(boolean flip)
Flip the image in the image viewer horizontally

Parameters:
flip - true to flip, else false


Copyright 2006. All Rights Reserved.