|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ridgesoft.robotics.sensors.CMUcam.CMUcamBase
public abstract class CMUcamBase
Base class for classes that interface with the CMUcam and CMUcam2.
Field Summary | |
---|---|
static int |
FPS_11
Clock register setting for 11 frames per second. |
static int |
FPS_13
Clock register setting for 13 frames per second. |
static int |
FPS_17
Clock register setting for 17 frames per second. |
static int |
FPS_5
Clock register setting for 5 frames per second. |
static int |
FPS_6
Clock register setting for 6 frames per second. |
static int |
FPS_7
Clock register setting for 7 frames per second. |
static int |
FPS_8
Clock register setting for 8 frames per second. |
static int |
FPS_9
Clock register setting for 9 frames per second. |
static int |
LED_OFF
Tracking LED mode value to turn the LED off. |
static int |
LED_ON
Tracking LED mode value to turn the LED on. |
static int |
LED_TRACK
Tracking LED mode value to give the camera control of the LED. |
Constructor Summary | |
---|---|
protected |
CMUcamBase(SerialPort serialPort,
int baudRate)
Initializes the camera base class. |
Method Summary | |
---|---|
void |
addCameraListener(CMUcamDataListener listener)
Adds a listener for CMUcamData updates. |
void |
close()
Closes communication with the camera by issuing an idle command to the camera and terminating the receive and listener threads. |
CMUcamHistogramData |
getHistogramData()
Retrieves the latest histogram data reported by the CMUcam2. |
Thread |
getListenerThread()
Gets the camera's listener thread. |
void |
getMean()
Issues the get mean command to the camera, instructing it to start sending statistic data. |
Thread |
getReceiveThread()
Gets the camera's receiver thread. |
int |
getRxErrors()
Gets the count of receive errors. |
CMUcamStatisticData |
getStatisticData()
Retrieves the latest statistic data reported by the camera. |
CMUcamTrackingData |
getTrackingData()
Retrieves the latest tracking data reported by the camera. |
boolean |
isTracking()
Returns whether the camera is currently tracking. |
void |
open()
Opens communication with the camera and resets the camera. |
protected abstract void |
processMessage(byte[] message)
Camera version specific message processing method. |
void |
removeCameraListener(CMUcamDataListener listener)
Removes the listener. |
void |
reset()
Issues a reset command to the camera. |
protected void |
sendBooleanCommand(String command,
boolean value)
Sends a command to the camera followed by the boolean value converted to 0 for false and 1 for true. |
void |
sendCommand(String command)
Sends a command to the camera and waits for a response. |
void |
sendCommand(String command,
boolean expectPrompt)
Sends a command to the camera and waits for a response. |
void |
setAutoExposure(boolean autoExposure)
Enables or disables auto exposure. |
void |
setBrightness(int brightness)
Sets the camera's brightness. |
void |
setCameraRegister(int register,
int value)
Sets a camera register. |
void |
setContrast(int contrast)
Sets the camera's contrast. |
void |
setDebug(boolean debug)
Enables or disables debug mode. |
void |
setFrameRate(int clockRegisterSetting)
Sets the camera's frame rate. |
void |
setIsTracking(boolean isTracking)
Sets the variable this class uses to maintian the tracking state. |
void |
setRGBMode(boolean rgbModeEnabled)
Sets the color mode to RGB or YCrCb. |
protected void |
setTFrameSize(int size)
Sets the size to expect for a T frame. |
void |
setTrackingLed(int led,
int mode)
Sets the state of a tracking LED. |
void |
setWhiteBalance(boolean whiteBalance)
Enables or disables automatic white balance adjustment. |
void |
stop()
Issues an idle command to the camera which will cause it to stop sending tracking data. |
void |
trackBlue()
Sets tracking to blue objects. |
void |
trackColor()
Issues the track color command to the camera, instructing it to track using existing color tracking parameters. |
void |
trackColor(int redOrCrMinimum,
int redOrCrMaximum,
int greenOrYMinimum,
int greenOrYMaximum,
int blueOrCbMinimum,
int blueOrCbMaximum)
Issues the track color command to the camera, instructing it to track using the specified color tracking parameters. |
void |
trackGreen()
Sets tracking to green objects. |
void |
trackRed()
Sets tracking to red objects. |
void |
trackWindow()
Issues the track window command to the camera, instructing it to track the color found in the center of the current window. |
protected void |
updateHistogramData(CMUcamHistogramData histogramData)
Updates histogram data with new data. |
protected void |
updateStatisticData(CMUcamStatisticData statisticData)
Updates statistic data with new data. |
protected void |
updateTrackingData(CMUcamTrackingData trackingData)
Updates tracking data with new data. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Field Detail |
---|
public static final int FPS_11
public static final int FPS_13
public static final int FPS_17
public static final int FPS_5
public static final int FPS_6
public static final int FPS_7
public static final int FPS_8
public static final int FPS_9
public static final int LED_OFF
public static final int LED_ON
public static final int LED_TRACK
Constructor Detail |
---|
protected CMUcamBase(SerialPort serialPort, int baudRate)
serialPort
- serial port object for the port the camera attaches tobaudRate
- baud rate to use to communicate with the cameraMethod Detail |
---|
public void addCameraListener(CMUcamDataListener listener)
This class currently only supports one listener. If the listener method takes too long to execute some messages may not be reported. Care must be taken to account for the listener being called on a separate thread to avoid synchronization problems. Calls to the listener are serialized so the and the listener method will not be re-entered.
listener
- a reference to a class implementing the CMUcamDataListener
interfacepublic void close()
public CMUcamHistogramData getHistogramData()
This function is not supported by the original camera.
public Thread getListenerThread()
public void getMean() throws IOException
IOException
public Thread getReceiveThread()
public int getRxErrors()
Receive errors may be caused by a poor quality connection, running the camera at a higher baud rate than the microcontroller supports, the camera receive thread running at too low a priority, or bad data from the camera.
public CMUcamStatisticData getStatisticData()
public CMUcamTrackingData getTrackingData()
public boolean isTracking()
Note: The value returned is based on a this class keeping tracking of the commands it has sent to the camera. If the camera gets reset externally or the sendCommand method is used directly to turn on tracking, the value returned by this method may not be correct.
public void open() throws IOException
IOException
- if communication to the camera fails. This exception will be
thrown if the camera is not attached or turned off.protected abstract void processMessage(byte[] message)
message
- The message to process.public void removeCameraListener(CMUcamDataListener listener)
listener
- a reference to a class implementing the CMUcamDataListener
interfacepublic void reset() throws IOException
IOException
protected void sendBooleanCommand(String command, boolean value) throws IOException
command
- command string prefixvalue
- boolean value to be appended to the command string as 0 or 1
IOException
public void sendCommand(String command) throws IOException
This method should only be used when no other method is available to configure the camera. Using this method may result in the putting the camera in a mode that is not handled by this class. This method sends the command and waits for the response from the camera.
command
- an ASCII command to send to the camera, including all data
except the '\r' character
IOException
public void sendCommand(String command, boolean expectPrompt) throws IOException
This method should only be used when no other method is available to configure the camera. Using this method may result in the putting the camera in a mode that is not handled by this class. This method sends the command and waits for the response from the camera.
command
- an ASCII command to send to the camera, including all data
except the '\r' characterexpectPrompt
- true if a prompt (":") should be expected after the command
IOException
public void setAutoExposure(boolean autoExposure) throws IOException
autoExposure
- true (default) enables auto exposure false disables auto
exposure
IOException
public void setBrightness(int brightness) throws IOException
brightness
- 0 - 255
IOException
public void setCameraRegister(int register, int value) throws IOException
Other methods are provided for common register setting commands.
This method should only be used when no other method is available.
See the camera documentation for more information regarding the camera registers.
register
- number of the register to setvalue
- value to set in the register (0 - 255)
IOException
public void setContrast(int contrast) throws IOException
contrast
- 0 - 255
IOException
public void setDebug(boolean debug)
In debug mode this class prints commands to the camera and command responses from the camera to System.out. Tracking and statistic data updates are not displayed.
debug
- true turns on debugging mode, false (default) turns off
debugging modepublic void setFrameRate(int clockRegisterSetting) throws IOException
Slowing the frame rate down reduces the processing overhead for the robotics controller, leaving more computing power to do other things.
clockRegisterSetting
- value to write into the camera's clock register
Note: This value is NOT the number of frames per second.
Use one of the following defined constants for this parameter:
IOException
public void setIsTracking(boolean isTracking)
If the camera is put into tracking mode directly by using the sendCommand method, this method should be used to set the tracking variable correctly.
Most users should not need to use sendCommand or this method. Using this method from your application should be avoided.
isTracking
- true if the camera is in the tracking statepublic void setRGBMode(boolean rgbModeEnabled) throws IOException
rgbModeEnabled
- true enables RGB mode, false enables YCrCb mode
IOException
protected void setTFrameSize(int size)
size
- size of T frame not including type bytepublic void setTrackingLed(int led, int mode) throws IOException
led
- number of the LEDmode
- LED mode
IOException
public void setWhiteBalance(boolean whiteBalance) throws IOException
whiteBalance
- true enables automatic white balance adjustment, false
(default) disables automatic white balance adjustment
IOException
public void stop() throws IOException
IOException
public void trackBlue() throws IOException
IOException
public void trackColor() throws IOException
IOException
public void trackColor(int redOrCrMinimum, int redOrCrMaximum, int greenOrYMinimum, int greenOrYMaximum, int blueOrCbMinimum, int blueOrCbMaximum) throws IOException
redOrCrMinimum
- minimum red or Cr color componentredOrCrMaximum
- maximum red or Cr color componentgreenOrYMinimum
- minimum green or Y color componentgreenOrYMaximum
- maximum green or Y color componentblueOrCbMinimum
- minimum blue or Cb color componentblueOrCbMaximum
- maximum blue or Cb color component
IOException
public void trackGreen() throws IOException
IOException
public void trackRed() throws IOException
IOException
public void trackWindow() throws IOException
IOException
protected void updateHistogramData(CMUcamHistogramData histogramData)
This method is intended to be called by the processMessage method.
histogramData
- new histogram dataprotected void updateStatisticData(CMUcamStatisticData statisticData)
This method is intended to be called by the processMessage method.
statisticData
- new statistic dataprotected void updateTrackingData(CMUcamTrackingData trackingData)
This method is intended to be called by the processMessage method.
trackingData
- new tracking data
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |