Package lejos.hardware.device
Class NXTCam
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.NXTCam
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class NXTCam extends I2CSensor
Mindsensors NXTCam. www.mindsensors.com Author Lawrie Griffiths
-
-
Field Summary
Fields Modifier and Type Field Description static charCOLORUsed by sortBy() to choose sorting criteria based on color id (ordered 0 to 7).static charLINE_TRACKINGUsed by setTrackingMode() to choose line tracking.static charNO_SORTINGUsed by sortBy() to choose no sorting of detected objects.static charOBJECT_TRACKINGUsed by setTrackingMode() to choose object tracking.static charSIZEUsed by sortBy() to choose sorting criteria based on size (ordered largest to smallest).-
Fields inherited from class lejos.hardware.sensor.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenableTracking(boolean enable)java.lang.StringgetFirmwareVersion()Returns the NXTCam firmware version.intgetNumberOfObjects()Get the number of objects being trackedintgetObjectColor(int id)Get the color number for a tracked objectRectangle2DgetRectangle(int id)Get the rectangle containing a tracked objectvoidsendCommand(char cmd)Send a single byte command represented by a lettervoidsetTrackingMode(char mode)Choose either object or line tracking mode.voidsortBy(char sortType)Camera sorts objects it detects according to criteria, either color, size, or no sorting at all.-
Methods inherited from class lejos.hardware.sensor.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Field Detail
-
SIZE
public static final char SIZE
Used by sortBy() to choose sorting criteria based on size (ordered largest to smallest).- See Also:
- Constant Field Values
-
COLOR
public static final char COLOR
Used by sortBy() to choose sorting criteria based on color id (ordered 0 to 7).- See Also:
- Constant Field Values
-
NO_SORTING
public static final char NO_SORTING
Used by sortBy() to choose no sorting of detected objects.- See Also:
- Constant Field Values
-
OBJECT_TRACKING
public static final char OBJECT_TRACKING
Used by setTrackingMode() to choose object tracking.- See Also:
- Constant Field Values
-
LINE_TRACKING
public static final char LINE_TRACKING
Used by setTrackingMode() to choose line tracking.- See Also:
- Constant Field Values
-
-
Method Detail
-
getNumberOfObjects
public int getNumberOfObjects()
Get the number of objects being tracked- Returns:
- number of objects (0 - 8)
-
sortBy
public void sortBy(char sortType)
Camera sorts objects it detects according to criteria, either color, size, or no sorting at all.- Parameters:
sortType- Use the class constants SIZE, COLOR, or NO_SORTING.
-
enableTracking
public void enableTracking(boolean enable)
- Parameters:
enable- true to enable, false to disable
-
setTrackingMode
public void setTrackingMode(char mode)
Choose either object or line tracking mode.- Parameters:
mode- Use either OBJECT_TRACKING or LINE_TRACKING
-
getObjectColor
public int getObjectColor(int id)
Get the color number for a tracked object- Parameters:
id- the object number (starting at zero)- Returns:
- the color of the object (starting at zero)
-
getFirmwareVersion
public java.lang.String getFirmwareVersion()
Returns the NXTCam firmware version.- Returns:
- version number as a string
-
getRectangle
public Rectangle2D getRectangle(int id)
Get the rectangle containing a tracked object- Parameters:
id- the object number (starting at zero)- Returns:
- the rectangle
-
sendCommand
public void sendCommand(char cmd)
Send a single byte command represented by a letter- Parameters:
cmd- the letter that identifies the command
-
-