public class NXTCam extends I2CSensor
Modifier and Type | Field and Description |
---|---|
static char |
COLOR
Used by sortBy() to choose sorting criteria based on color id (ordered 0 to 7).
|
static char |
LINE_TRACKING
Used by setTrackingMode() to choose line tracking.
|
static char |
NO_SORTING
Used by sortBy() to choose no sorting of detected objects.
|
static char |
OBJECT_TRACKING
Used by setTrackingMode() to choose object tracking.
|
static char |
SIZE
Used by sortBy() to choose sorting criteria based on size (ordered largest to smallest).
|
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
currentMode, modes
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
Constructor and Description |
---|
NXTCam(I2CPort port) |
NXTCam(I2CPort port,
int address) |
NXTCam(Port port) |
NXTCam(Port port,
int address) |
Modifier and Type | Method and Description |
---|---|
void |
enableTracking(boolean enable) |
java.lang.String |
getFirmwareVersion()
Returns the NXTCam firmware version.
|
int |
getNumberOfObjects()
Get the number of objects being tracked
|
int |
getObjectColor(int id)
Get the color number for a tracked object
|
Rectangle2D |
getRectangle(int id)
Get the rectangle containing a tracked object
|
void |
sendCommand(char cmd)
Send a single byte command represented by a letter
|
void |
setTrackingMode(char mode)
Choose either object or line tracking mode.
|
void |
sortBy(char sortType)
Camera sorts objects it detects according to criteria, either color, size,
or no sorting at all.
|
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
public static final char SIZE
public static final char COLOR
public static final char NO_SORTING
public static final char OBJECT_TRACKING
public static final char LINE_TRACKING
public NXTCam(I2CPort port, int address)
public NXTCam(I2CPort port)
public NXTCam(Port port, int address)
public NXTCam(Port port)
public int getNumberOfObjects()
public void sortBy(char sortType)
sortType
- Use the class constants SIZE, COLOR, or NO_SORTING.public void enableTracking(boolean enable)
enable
- true to enable, false to disablepublic void setTrackingMode(char mode)
mode
- Use either OBJECT_TRACKING or LINE_TRACKINGpublic int getObjectColor(int id)
id
- the object number (starting at zero)public java.lang.String getFirmwareVersion()
public Rectangle2D getRectangle(int id)
id
- the object number (starting at zero)public void sendCommand(char cmd)
cmd
- the letter that identifies the command