dLife Home Page

dlife.vision.cameras.sources
Class ImageVideoSource

java.lang.Object
  extended by java.util.Observable
      extended by dlife.vision.VideoSource
          extended by dlife.vision.cameras.sources.ImageVideoSource

public class ImageVideoSource
extends VideoSource

A VideoSource for a static image. The image can be in any format that is supported by the ImageIO.read method in the javax.imageio package. This includes at least bmp, wbmp, jpeg, gif, and png images. Running the main method in this class will display a list of all of the recognized image formats.

Version:
Jun 25, 2009
Author:
Grant Braught, Dickinson College

Field Summary
 
Fields inherited from class dlife.vision.VideoSource
loop
 
Constructor Summary
ImageVideoSource()
          Use a JFileChooser to allow the user to select the image file to be used for this ImageVideoSource.
ImageVideoSource(URL imageURL)
          Construct a new ImageVideoSource for the image at the specified URL.
 
Method Summary
 boolean canLoop()
          An ImageVideoSource cannot loop.
 boolean canPause()
          An ImageVideoSource cannot be paused.
 boolean canPlay()
          An ImageVideoSource acts as if it is always in the paused state.
 boolean canRewind()
          An ImageVideoSource cannot be rewound.
 boolean canSeek()
          An ImageVideoSource cannot seek.
 boolean canStepBackward()
          An ImageVideoSource cannot step backward.
 boolean canStepForward()
          An ImageVideoSource cannot step forward.
 void connect()
          Load the image for this ImageVideoSource.
 void disconnect()
          Disconnect from the ImageVideoSource.
 VideoSourceGUI getGUI()
          Get the VideoPlayerGUI that will control this ImageVideoSource.
 int getHeight()
          Get the width of the image associated with this ImageVideoSource.
 int getSeekLocation()
          An ImageVideoSource cannot seek so this method returns -1.
 BufferedImage getVideoFrame()
          This method returns the image specified when this ImageVideoSource was constructed.
 int getWidth()
          Get the height of the image associated with this ImageVideoSource.
static void main(String[] args)
          Little test method that creates and displays a Camera (and all of the GUI parts) using an ImageVideoSource as the video source.
 void pause()
          An ImageVideoSource cannot be paused so this method does nothing in this implementation.
 void play()
          When play is called the ImageVideoSource simply notifies the observers that a new image is available for display.
 void rewind()
          An ImageVideoSource cannot be rewound so this method does nothing in this implementation.
 void seek(int location)
          An ImageVideoSource cannot seek so this method does nothing in this implementation.
 void stepBackward()
          An ImageVideoSource cannot be stepped backward so this method does nothing in this implementation.
 void stepForward()
          An ImageVideoSource cannot be stepped forward so this method does nothing in this implementation.
 
Methods inherited from class dlife.vision.VideoSource
isLooping, setLoop
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageVideoSource

public ImageVideoSource()
                 throws VideoSourceCreationFailedException
Use a JFileChooser to allow the user to select the image file to be used for this ImageVideoSource.

Throws:
VideoSourceCreationFailedException - if the user cancels the creation or if the file selected by the user cannot be read.

ImageVideoSource

public ImageVideoSource(URL imageURL)
                 throws VideoSourceCreationFailedException
Construct a new ImageVideoSource for the image at the specified URL. The URL may be a file URL on the local computer or it may be a URL pointing to an image accessible via the network.

Parameters:
imageURL - the URL of the image for the new ImageVideoSource.
Throws:
VideoSourceCreationFailedException
Method Detail

connect

public void connect()
             throws VideoSourceConnectionException
Load the image for this ImageVideoSource.

Specified by:
connect in class VideoSource
Throws:
VideoSourceConnectionException - if the image file cannot be read.

disconnect

public void disconnect()
Disconnect from the ImageVideoSource. This method does nothing.

Specified by:
disconnect in class VideoSource

getGUI

public VideoSourceGUI getGUI()
Get the VideoPlayerGUI that will control this ImageVideoSource. This is the GUI that will be displayed by the Camera for controlling the VideoSource.

Specified by:
getGUI in class VideoSource
Returns:
a VideoPlayerGUI for controlling the VideoSource.

canPause

public boolean canPause()
An ImageVideoSource cannot be paused.

Specified by:
canPause in class VideoSource
Returns:
false

canPlay

public boolean canPlay()
An ImageVideoSource acts as if it is always in the paused state. Thus this method returns true.

Specified by:
canPlay in class VideoSource
Returns:
true

canRewind

public boolean canRewind()
An ImageVideoSource cannot be rewound.

Specified by:
canRewind in class VideoSource
Returns:
false

canStepBackward

public boolean canStepBackward()
An ImageVideoSource cannot step backward.

Specified by:
canStepBackward in class VideoSource
Returns:
false

canStepForward

public boolean canStepForward()
An ImageVideoSource cannot step forward.

Specified by:
canStepForward in class VideoSource
Returns:
false

canLoop

public boolean canLoop()
An ImageVideoSource cannot loop.

Specified by:
canLoop in class VideoSource
Returns:
false

canSeek

public boolean canSeek()
An ImageVideoSource cannot seek.

Specified by:
canSeek in class VideoSource
Returns:
false

getVideoFrame

public BufferedImage getVideoFrame()
This method returns the image specified when this ImageVideoSource was constructed.

Specified by:
getVideoFrame in class VideoSource
Returns:
the most recent frame of video or null if no frame is available.

pause

public void pause()
An ImageVideoSource cannot be paused so this method does nothing in this implementation.

Specified by:
pause in class VideoSource

play

public void play()
When play is called the ImageVideoSource simply notifies the observers that a new image is available for display. Technically an ImageVideoSource cannot be played, but the Camera class invokes play when the Camera is started up so that it starts playing with images displayed. So this is a little hack to get the image to display when the Camera opens.

Specified by:
play in class VideoSource

rewind

public void rewind()
An ImageVideoSource cannot be rewound so this method does nothing in this implementation.

Specified by:
rewind in class VideoSource

stepBackward

public void stepBackward()
An ImageVideoSource cannot be stepped backward so this method does nothing in this implementation.

Specified by:
stepBackward in class VideoSource

stepForward

public void stepForward()
An ImageVideoSource cannot be stepped forward so this method does nothing in this implementation.

Specified by:
stepForward in class VideoSource

seek

public void seek(int location)
An ImageVideoSource cannot seek so this method does nothing in this implementation.

Specified by:
seek in class VideoSource
Parameters:
location - the location to which to seek.

getSeekLocation

public int getSeekLocation()
An ImageVideoSource cannot seek so this method returns -1.

Specified by:
getSeekLocation in class VideoSource
Returns:
-1

getHeight

public int getHeight()
Get the width of the image associated with this ImageVideoSource.

Specified by:
getHeight in class VideoSource
Returns:
the width of the image, or -1 if this ImageVideoSource is not connected.

getWidth

public int getWidth()
Get the height of the image associated with this ImageVideoSource.

Specified by:
getWidth in class VideoSource
Returns:
the height of the image or -1 if this ImageVideoSource is not connected.

main

public static void main(String[] args)
Little test method that creates and displays a Camera (and all of the GUI parts) using an ImageVideoSource as the video source. The user is asked to select a directory containing the images to use.

Parameters:
args - none

dLife Home Page