devs.visionpackage.org.cmotch.robovision
Class VisionImage

java.lang.Object
  extended by devs.visionpackage.org.cmotch.robovision.VisionImage

public class VisionImage
extends java.lang.Object

Class that represents the image that was captured from the camera This includes methods to allow the caller to find out what objects were seen, if any, and what colour they were.


Field Summary
static byte BLUE
           
static byte EDGE
           
static byte EMPTY
           
static byte GREEN
           
static byte NO_COLOUR
           
static byte NUMBER_OF_COLOURS
           
static byte OCCUPIED
           
static byte RED
           
 
Constructor Summary
VisionImage(java.awt.Image image)
          Constructor
 
Method Summary
 boolean canYouSee(byte colour)
          Look for coloured object.
 boolean[] getColoursSeen()
          Get the colours, if any, that were seen in the image.
 int getHeight()
          Get the height of the image
 java.awt.Image getImage()
          Get the raw Image object (can be used for display)
 int getPixel(int x, int y)
          Get the value of a particular pixel
 int[] getPixelMap()
          Get the pixel map for this image
 VisionObject getVisionObject(byte colour)
          Get the information about an object viewed by the robot
 int getWidth()
          Get the width of the image
 void setDebugLevel(int level)
          Set debug level
 boolean testPixelColour(int pixel, byte colour)
          Determine whether a pixel is of a particular colour using the thresholds array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RED

public static final byte RED
See Also:
Constant Field Values

GREEN

public static final byte GREEN
See Also:
Constant Field Values

BLUE

public static final byte BLUE
See Also:
Constant Field Values

NUMBER_OF_COLOURS

public static final byte NUMBER_OF_COLOURS
See Also:
Constant Field Values

NO_COLOUR

public static final byte NO_COLOUR
See Also:
Constant Field Values

EMPTY

public static final byte EMPTY
See Also:
Constant Field Values

EDGE

public static final byte EDGE
See Also:
Constant Field Values

OCCUPIED

public static final byte OCCUPIED
See Also:
Constant Field Values
Constructor Detail

VisionImage

public VisionImage(java.awt.Image image)
            throws VisionException
Constructor

Parameters:
image - The source image from the camera
Throws:
VisionException - If the image is unusable
Method Detail

setDebugLevel

public void setDebugLevel(int level)
Set debug level


getWidth

public int getWidth()
Get the width of the image

Returns:
The width of the image

getHeight

public int getHeight()
Get the height of the image

Returns:
The height of the image

getImage

public java.awt.Image getImage()
Get the raw Image object (can be used for display)

Returns:
The initial image

getPixelMap

public int[] getPixelMap()
Get the pixel map for this image

Returns:
The pixel array for this image

getPixel

public int getPixel(int x,
                    int y)
Get the value of a particular pixel

Parameters:
x - The X co-ordinate of the pixel
y - The Y co-ordinate of the pixel

getColoursSeen

public boolean[] getColoursSeen()
Get the colours, if any, that were seen in the image.

NOTE: These vision algorithms are quite simple, so we restrict our processing to the primary colours red, blue and green. If you put a non-primary coloured object in the field of view it may well appear as two objects in the same place.


testPixelColour

public boolean testPixelColour(int pixel,
                               byte colour)
Determine whether a pixel is of a particular colour using the thresholds array

Parameters:
pixel - The pixel to check
colour - The colour to test the pixel for
Returns:
Whether the pixel is of this colour or not

canYouSee

public boolean canYouSee(byte colour)
Look for coloured object. This will be useful if there could be more than one object in the field of view.

Parameters:
colour - The colour of the object to look for

getVisionObject

public VisionObject getVisionObject(byte colour)
Get the information about an object viewed by the robot

Parameters:
colour - The colour to look for (NO_COLOUR means any colour, which will be the first of red, blue or green that was seen