|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
dlife.robot.Device
dlife.vision.Camera
public class Camera
Base class for creating cameras for different image sources. Users will
typically interact with one of the Camera sub-classes defined in
dlife.vision.cameras rather than with this class directly.
A Camera provides programmatic control for drawing on the video, controlling the play of the video, and adding and manipulating filters that are applied to the video. It also provides 2 GUI elements when added to a Robot. The Camera GUI displays the raw and filtered video and provides controls for playing/pausing/rewinding/etc and the Filters GUI provides a means for adding/editing/removing filters.
A Camera contains a VideoSource, a FilterManager and a VideoDisplay. Each of these objects can be controlled via its own methods. However, the Camera class contains convenience methods that allow the methods of those objects to be invoked from the Camera object. This is done so that code in a Controller need only interact with the Camera object.
| Field Summary | |
|---|---|
static int |
BOTH_VIDEO
Constant used by the drawing methods to indicate that the drawing command should be applied to both the raw and filtered video window. |
static int |
FILTERED_VIDEO
Constant used by the drawing methods to indicate that the drawing commands should be applied to the filtered video window. |
static int |
RAW_VIDEO
Constant used by the drawing methods to indicate that the drawing commands should be applied to the raw video window. |
| Fields inherited from class dlife.robot.Device |
|---|
DEFAULT_GUI_UPDATE_DELAY, DEFAULT_READ_DELAY, myRobot, readCount |
| Constructor Summary | |
|---|---|
Camera(VideoSource src)
Construct a new Camera that will control, process and display the video from the specified VideoSource. |
|
Camera(VideoSource src,
FilterManager mgr,
VideoDisplay disp)
Construct a new Camera using the specified VideoSource, FilterManger and VideoDisplay objects. |
|
| Method Summary | |
|---|---|
void |
addFilter(Filter f)
Add the Filter f to the FilterManager for this Camera. |
void |
clearDrawing(int window)
Clears everything that has been drawn on the VideoDisplay associated with this Camera. |
protected DeviceDisplay[] |
createGUIObjects()
Create the GUI for the Camera. |
void |
drawCircle(int window,
int x,
int y,
int radius,
Color color,
boolean filled)
Draw a circle overlaid on the VideoDisplay associated with this Camera. |
void |
drawLine(int window,
int x1,
int y1,
int x2,
int y2,
Color color)
Draw a line segment overlaid on the VideoDisplay associated with this Camera. |
void |
drawOval(int window,
int x,
int y,
int width,
int height,
Color color,
boolean filled)
Draw an oval overlaid on the VideoDisplay associated with this Camera. |
void |
drawRectangle(int window,
int x,
int y,
int width,
int height,
Color color,
boolean filled)
Draw a rectangle overlaid on the VideoDisplay associated with this Camera. |
void |
drawString(int window,
String str,
int x,
int y,
Color color)
Draw a string of text overlaid on the VideoDisplay associated with this Camera. |
void |
freeze()
Does nothing. |
FilterManager |
getFilterManager()
Get the FilterManager associated with this Camera. |
ArrayList<Filter> |
getFilters()
Get the current chain of Filters from the FilterManager associated with this Camera. |
int |
getHeight()
Get the height, in pixels, of the video being displayed by this Camera. |
int |
getSeekLocation()
Get the current seek location of this Camera. |
VideoDisplay |
getVideoDisplay()
Get the VideoDisplay associated with this Camera. |
VideoSource |
getVideoSource()
Get the VideoSource associated with this Camera. |
int |
getWidth()
Get the width, in pixels, of the video being displayed by this Camera. |
void |
insertFilter(int index,
Filter f)
Insert the specified Filter at the specified index in the FilterManager associated with this Camera. |
void |
pause()
Stops the VideoSource associated with this Camera. |
void |
play()
Play the VideoSource associated with this Camera. |
void |
readStateFromRobot()
Does nothing. |
void |
removeFilter(Filter f)
Remove the specified Filter from the FilterManager associated with this Camera. |
void |
removeFilter(int index)
Remove the Filter currently located at the specified index from the FilterManager for this Camera. |
void |
rewind()
Rewind the VideoSource associated with this Camera. |
void |
seek(int location)
Seek the VideoSource associated with this Camera to the specified location. |
void |
setFilters(ArrayList<Filter> newFilters)
Replaces the current list of filters in the FilterManager associated with this Camera with the provided list of Filters. |
void |
shutDown()
Shutdown the Camera. |
void |
startUp()
Start up the Camera. |
void |
stepBackward()
Step the VideoSource associated with this Camera back by one frame. |
void |
stepForward()
Advance the VideoSource associated with this Camera by one frame. |
void |
update(Observable o,
Object arg)
The Camera will be notified each time a new image is available from the VideoSource. |
| Methods inherited from class dlife.robot.Device |
|---|
getAutoRead, getGUI, getGUIUpdateDelay, getReadDelay, getRobot, getSensorReadCount, getSensorReadRate, setAutoRead, setGUIUpdateDelay, setReadDelay, setRobot, startAutoReadTimer, stopAutoReadTimer |
| 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 |
| Field Detail |
|---|
public static int RAW_VIDEO
public static int FILTERED_VIDEO
public static int BOTH_VIDEO
| Constructor Detail |
|---|
public Camera(VideoSource src)
src - the VideoSource for this Camera.
public Camera(VideoSource src,
FilterManager mgr,
VideoDisplay disp)
src - the VideoSource.mgr - the FilterManager.disp - the VideoDisplay.| Method Detail |
|---|
public void startUp()
startUp in class Devicepublic void shutDown()
shutDown in class Devicepublic void freeze()
freeze in class Devicepublic void readStateFromRobot()
readStateFromRobot in class Deviceprotected DeviceDisplay[] createGUIObjects()
createGUIObjects in class Devicepublic VideoSource getVideoSource()
public FilterManager getFilterManager()
public VideoDisplay getVideoDisplay()
public void update(Observable o,
Object arg)
When notified the Camera will get that image, pass it through the filter chain and then display both the raw and filtered images in the VideoDisplay.
update in interface Observerpublic void play()
VideoSource.play()public void pause()
VideoSource.pause()public void rewind()
VideoSource.rewind()public void stepForward()
VideoSource.stepForward()public void stepBackward()
VideoSource.stepBackward()public void seek(int location)
location - the location to which to seek.VideoSource.seek(int location)public int getSeekLocation()
VideoSource.getSeekLocation()public int getWidth()
VideoSource.getWidth()public int getHeight()
VideoSource.getHeight()public void addFilter(Filter f)
f - the filter to add.FilterManager.addFilter(Filter)public void removeFilter(int index)
index - the index from which to remove the Filter.FilterManager.removeFilter(int)public void removeFilter(Filter f)
f - the Filter to remove.FilterManager.removeFilter(Filter)
public void insertFilter(int index,
Filter f)
index - the index at which to insert f.f - the Filter to insert.FilterManager.insertFilter(int, Filter)public ArrayList<Filter> getFilters()
The returned list of Filters is a shallow copy of the actual list maintained by the FilterManager. Thus, changing the behavior of the Filter objects in the returned list will change the filtering that is performed. However, changing the order or adding or removing filters from the list will have no effect on the filtering performed.
FilterManager.getFilters()public void setFilters(ArrayList<Filter> newFilters)
newFilters - the new set of filters to use.FilterManager.setFilters(ArrayList)
public void drawRectangle(int window,
int x,
int y,
int width,
int height,
Color color,
boolean filled)
window - either RAW_VIDEO, FILTERED_VIDEO or BOTH_VIDEO indicating
the window on which to draw the rectangle.x - x coordinate of upper left corner of the rectangle.y - y coordinate of the upper left corner of the rectangle.width - width of the rectangle.height - height of the rectangle.color - color of the line (and fill) of the rectangle.filled - true to fill in the rectangle.
public void drawOval(int window,
int x,
int y,
int width,
int height,
Color color,
boolean filled)
window - either RAW_VIDEO, FILTERED_VIDEO or BOTH_VIDEO indicating
the window on which to draw the oval.x - x coordinate of the upper left corner of the oval's bounding
box.y - y coordinate of the upper right corner of the oval's bounding
box.width - width of the oval's bounding box.height - height of the oval's bounding box.color - color of the line (and fill) of the oval.filled - true to fill in the oval.
public void drawCircle(int window,
int x,
int y,
int radius,
Color color,
boolean filled)
window - either RAW_VIDEO, FILTERED_VIDEO or BOTH_VIDEO indicating
the window on which to draw the circle.x - x coordinate of the center of the circle.y - y coordinate of the center of the circle.radius - radius of the circle.color - color of the line (and fill) of the circle.filled - true to fill the circle.
public void drawLine(int window,
int x1,
int y1,
int x2,
int y2,
Color color)
window - either RAW_VIDEO, FILTERED_VIDEO or BOTH_VIDEO indicating
the window on which to draw the line segment.x1 - x coordinate of one end point of the line segment.y1 - y coordinate of one end point of the line segment.x2 - x coordinate of the other end point of the line segment.y2 - y coordinate of the other end point of the line segment.color - the color of the line.
public void drawString(int window,
String str,
int x,
int y,
Color color)
window - either RAW_VIDEO, FILTERED_VIDEO or BOTH_VIDEO indicating
the window on which to draw the string.str - the string to add.x - x coordinate of the baseline of the first character.y - y coordinate of the baseline of the first character.color - the color of the text.public void clearDrawing(int window)
window - either RAW_VIDEO, FILTERED_VIDEO or BOTH_VIDEO indicating
which window should be cleared.
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||