lejos.nxt.addon
Class NXTCam

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.NXTCam
All Implemented Interfaces:
SensorConstants

public class NXTCam
extends I2CSensor

Mindsensors NXTCam. www.mindsensors.com Author Lawrie Griffiths


Field Summary
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).
 
Fields inherited from class lejos.nxt.I2CSensor
PRODUCT_ID, SENSOR_TYPE, VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, 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
 
Constructor Summary
NXTCam(I2CPort port)
           
 
Method Summary
 void enableTracking(boolean enable)
           
 int getNumberOfObjects()
          Get the number of objects being tracked
 int getObjectColor(int id)
          Get the color number for a tracked object
 Rectangle 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.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getData, getPort, getProductID, getSensorType, getVersion, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

NXTCam

public NXTCam(I2CPort port)
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)

getRectangle

public Rectangle 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