|
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
com.ridgesoft.robotics.sensors.CMUcam.CMUcam2
public class CMUcam2
Class to interface with the CMUcam2.
This class manages communications with the camera, alleviating the need for to be concerned with the camera's communication protocol.
The documentation for this class describes the programming interface to this class. It does not describe how to use the camera. The camera user guide should be consulted to gain insight into how to use the camera and the purpose of each function provided by the camera.
The class provides for two methods of monitoring tracking data. The simplest method is by putting the camera into a tracking mode, then polling this class as needed to retrieve the latest tracking data, color statistics data or histogram data using the getTrackingData, getStatisticData and getHistogramData methods. The second method of monitoring tracking data is to register a listener class using the addCameraListener method. This class will then forward tracking data and statistic data to the listener as it is received from the camera. This method uses an additional thread to interface with the listener. If data arrives from the camera faster than it can be processed by the listener, some data will not be forwarded to the listener.
The open method must be called before calling methods that issue commands to the camera.
The following procedure may be used to receive camera tracking data:
This class creates two threads, one to receive data from the camera and the other to interface with the listener. The listener thread isn't started if the addCameraListener method isn't called.
By default, the camera receive thread runs at (Thread.NORM_PRIORITY + 2) and the listener thread runs at (Thread.NORM_PRIORITY + 1). These priorities may be changed by using the getListenerThread and getReceiveThread methods to get to the Thread objects.
Field Summary | |
---|---|
static int |
FPS_26
Clock register setting for 13 frames per second. |
static int |
FPS_50
Clock register setting for 50 frames per second. |
Fields inherited from class com.ridgesoft.robotics.sensors.CMUcam.CMUcamBase |
---|
FPS_11, FPS_13, FPS_17, FPS_5, FPS_6, FPS_7, FPS_8, FPS_9, LED_OFF, LED_ON, LED_TRACK |
Constructor Summary | |
---|---|
CMUcam2(SerialPort serialPort,
int baudRate)
Constructs a CMUcam object. |
Method Summary | |
---|---|
void |
defaultVirtualWindow()
Sets the default camera window (1, 1, 80, 143). |
void |
getHistogram(int channel)
Issues the get histogram command. |
void |
loadFrame()
Loads a baseline frame for motion differencing and motion tracking. |
protected void |
processMessage(byte[] message)
Camera version specific message processing method for the CMUcam2. |
void |
readFrame()
Reads a new frame into the buffer when using buffer mode. |
void |
reset()
Issues a reset command to the camera. |
void |
setBufferMode(boolean enabled)
Enables or disables buffer mode. |
void |
setCameraPower(boolean enabled)
Turns the camera power on or off. |
void |
setDifferencingChannel(int channel)
Sets the channel used for frame differencing. |
void |
setDownSampling(int xFactor,
int yFactor)
Sets down sampling factors. |
void |
setHighResolutionDifferencing(boolean enabled)
Enables or disables high resolution differencing. |
void |
setHighResolutionMode(boolean enabled)
Enables or disables high resolution mode. |
void |
setHistogramTracking(boolean enabled)
Enables or disables histogram tracking. |
void |
setNoiseFilter(int threshold)
Sets the noise filtering threshold. |
void |
setPacketFiltering(boolean enabled)
Enables or disables packet filtering mode. |
void |
setPacketSkip(int number)
Sets the number of packets to skip sending when tracking. |
void |
setPixelDifferencing(boolean enabled)
Enables or disables pixel difference mode. |
void |
setPixelFiltering(boolean enabled)
Enables or disables pixel filtering mode. |
void |
setServoMask(boolean panEnabled,
boolean tiltEnabled)
Enables or disables pan and tilt servos. |
void |
setServoParameters(int panRangeFar,
int panRangeNear,
int panStep,
int tiltRangeFar,
int tiltRangeNear,
int tiltStep)
Sets parameters to control the behavior of the pan and tilt servos. |
void |
setServoPosition(int servo,
int position)
Sets the servo position. |
void |
setTracking(int redOrCrMinimum,
int redOrCrMaximum,
int greenOrYMinimum,
int greenOrYMaximum,
int blueOrCbMinimum,
int blueOrCbMaximum)
Sets color tracking parameters, similar to trackColor but without initiating tracking. |
void |
setTrackInverted(boolean enabled)
Enables or disables track inverted mode. |
void |
setVirtualWindow(int x,
int y,
int x2,
int y2)
Sets the window bounds of the camera using the virtual window command. |
void |
sleep()
Puts the camera's CPU to sleep. |
void |
sleepDeeply()
Puts the camera into deep sleep mode to save power. |
void |
trackWithFrameDifferencing(int threshold)
Starts tracking with frame differencing using the specified threshold. |
void |
trackWithMaskedDifferencing(int threshold)
Starts tracking with masked differencing using the specified threshold. |
void |
wake()
Wakes the camera up after a sleep. |
Methods inherited from class com.ridgesoft.robotics.sensors.CMUcam.CMUcamBase |
---|
addCameraListener, close, getHistogramData, getListenerThread, getMean, getReceiveThread, getRxErrors, getStatisticData, getTrackingData, isTracking, open, removeCameraListener, sendBooleanCommand, sendCommand, sendCommand, setAutoExposure, setBrightness, setCameraRegister, setContrast, setDebug, setFrameRate, setIsTracking, setRGBMode, setTFrameSize, setTrackingLed, setWhiteBalance, stop, trackBlue, trackColor, trackColor, trackGreen, trackRed, trackWindow, updateHistogramData, updateStatisticData, updateTrackingData |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Field Detail |
---|
public static final int FPS_26
public static final int FPS_50
Constructor Detail |
---|
public CMUcam2(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 defaultVirtualWindow() throws IOException
IOException
public void getHistogram(int channel) throws IOException
The CMUcam2 will continually send updates to the histogram data.
channel
- channel to use
IOException
public void loadFrame() throws IOException
IOException
protected void processMessage(byte[] message)
processMessage
in class CMUcamBase
message
- message to processpublic void readFrame() throws IOException
IOException
public void reset() throws IOException
reset
in class CMUcamBase
IOException
public void setBufferMode(boolean enabled) throws IOException
enabled
- false frame buffer continuously updates (default) true a
single frame is buffered in the frame buffer
IOException
public void setCameraPower(boolean enabled) throws IOException
enabled
- false power off true power on
IOException
public void setDifferencingChannel(int channel) throws IOException
channel
- channel to use
IOException
public void setDownSampling(int xFactor, int yFactor) throws IOException
xFactor
- horizontal down sampling (default = 1, no down sampling)yFactor
- vertical down sampling factor
IOException
public void setHighResolutionDifferencing(boolean enabled) throws IOException
enabled
- high resolution differencing enable flag
IOException
public void setHighResolutionMode(boolean enabled) throws IOException
This is only supported with the OV6620 camera module.
enabled
- high resolution mode enable flag
IOException
public void setHistogramTracking(boolean enabled) throws IOException
When histogram tracking is enabled, only values that are within the color tracking bounds will be displayed in the histograms.
enabled
- false disabled (default) true enabled
IOException
public void setNoiseFilter(int threshold) throws IOException
threshold
- the number of consecutive active pixels before the current
pixel are required before the pixel should be detected
IOException
public void setPacketFiltering(boolean enabled) throws IOException
enabled
- false disabled (default) true enabled
IOException
public void setPacketSkip(int number) throws IOException
This is useful for slowing down the data rate from the camera.
number
- the number of packets to skip before sending the next packet
IOException
public void setPixelDifferencing(boolean enabled) throws IOException
enabled
- false disabled (default) true enabled
IOException
public void setPixelFiltering(boolean enabled) throws IOException
enabled
- false disabled (default) true enabled
IOException
public void setServoMask(boolean panEnabled, boolean tiltEnabled) throws IOException
Each position reporting field in tracking data objects are enabled when the associated servo is enabled.
panEnabled
- true - panning enabledtiltEnabled
- true - tilting enabled
IOException
public void setServoParameters(int panRangeFar, int panRangeNear, int panStep, int tiltRangeFar, int tiltRangeNear, int tiltStep) throws IOException
panRangeFar
- pixel distance needed to do a large pan steppanRangeNear
- pixel distance needed to do a small pan steppanStep
- servo position change for a long pan steptiltRangeFar
- pixel distance needed to do a large tilt steptiltRangeNear
- pixel distance needed to do a small tilt steptiltStep
- servo position change for a long tilt step
IOException
public void setServoPosition(int servo, int position) throws IOException
See the camera User Guide for more information.
servo
- number of the servo (1 - 5)position
- position to set
IOException
public void setTracking(int redOrCrMinimum, int redOrCrMaximum, int greenOrYMinimum, int greenOrYMaximum, int blueOrCbMinimum, int blueOrCbMaximum) throws IOException
The values are either specified as ranges for RGB or CrYCb values. The default is RGB, but it may be changed by using the setRGBMode method.
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 setTrackInverted(boolean enabled) throws IOException
When enabled, the camera will track colors outside of the color range, rather than inside the range.
enabled
- true - enables track inverted false - normal mode
IOException
public void setVirtualWindow(int x, int y, int x2, int y2) throws IOException
x
- x coordinate of upper left corner of desired windowy
- y coordinate of upper left corner of desired windowx2
- x coordinate of lower right corner of desired windowy2
- y coordinate of lower right corner of desired window
IOException
public void sleep() throws IOException
Use the wake method to wake the camera up.
IOException
public void sleepDeeply() throws IOException
Supporting circuitry must be added to the camera module to support this feature. See the camera User Guide for more information.
IOException
public void trackWithFrameDifferencing(int threshold) throws IOException
Differences are based on the last frame loaded using the loadFrame command.
threshold
- the threshold
IOException
public void trackWithMaskedDifferencing(int threshold) throws IOException
Differences are based on the last frame loaded using the loadFrame command.
threshold
- masked differencing threshold
IOException
public void wake() throws IOException
IOException
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |