VEX V5 C++ API
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
vex::vision Class Reference

Use this class when programming the vision sensor. More...

Inherits vex::device.

Classes

class  code
 Use this class when programming the vision sensor. More...
 
class  object
 The object class represents an object that the vision sensor detects. More...
 
class  signature
 Use this class when programming the vision sensor. More...
 

Public Types

enum  detectionMode { detectionMode::objectDetect = kVisionModeNormal, detectionMode::mixedDetect = kVisionModeMixed, detectionMode::lineDetect = kVisionModeLineDetect, detectionMode::test = kVisionTypeTest }
 
enum  whiteBalanceMode { whiteBalanceMode::automatic = kVisionWBNormal, whiteBalanceMode::start = kVisionWBStart, whiteBalanceMode::manual = kVisionWBManual }
 
enum  ledMode { ledMode::automatic = kVisionLedModeAuto, ledMode::manual = kVisionLedModeManual }
 
enum  wifiMode { wifiMode::off = kVisionWifiModeOff, wifiMode::on = kVisionWifiModeOn }
 

Public Member Functions

 vision (int32_t index)
 Creates a new vision object on the port specified. More...
 
 ~vision ()
 
template<typename... Args>
 vision (int32_t index, uint8_t bright, Args... sigs)
 Creates a new vision object on the port specified. Sets the brightness setting and all of the vision objects settings. More...
 
bool installed ()
 
int32_t value ()
 
int32_t takeSnapshot (uint32_t id)
 Takes a data sample from the vision sensor. More...
 
int32_t takeSnapshot (code &cc)
 Takes a data sample from the vision sensor. More...
 
int32_t takeSnapshot (signature &sig)
 Takes a data sample from the vision sensor. More...
 
int32_t takeSnapshot (uint32_t id, uint32_t count)
 Takes a data sample from the vision sensor, and only stores the largest samples of the specified amount. More...
 
int32_t takeSnapshot (code &cc, uint32_t count)
 Takes a data sample from the vision sensor, and only stores the largest samples of the specified amount. More...
 
int32_t takeSnapshot (signature &sig, uint32_t count)
 Takes a data sample from the vision sensor, and only stores the largest samples of the specified amount. More...
 
bool setSignature (V5_DeviceVisionSignature *pSignature)
 
bool getSignature (uint32_t id, V5_DeviceVisionSignature *pSignature)
 
bool setSignature (signature &sig)
 
bool getSignature (uint32_t id, signature &sig)
 
bool setMode (detectionMode mode)
 
detectionMode getMode (void)
 
bool setBrightness (uint8_t value)
 
uint8_t getBrightness (void)
 
bool setWhiteBalanceMode (whiteBalanceMode mode)
 
whiteBalanceMode getWhiteBalanceMode (void)
 
bool setWhiteBalanceValues (uint8_t red, uint8_t green, uint8_t blue)
 
bool getWhiteBalanceValues (uint8_t *red, uint8_t *green, uint8_t *blue)
 
bool setLedMode (ledMode mode)
 Changes the mode of the LED on the vision sensor. More...
 
ledMode getLedMode (void)
 Gets the mode of the LED from the vision sensor. More...
 
bool setLedBrightness (uint8_t percent)
 Changes the brightness of the LED on the vision sensor when LED is set to manual mode. More...
 
uint8_t getLedBrightness (void)
 Gets the brightness of the LED from the vision sensor. More...
 
bool setLedColor (uint8_t red, uint8_t green, uint8_t blue)
 Changes the color of the LED on the vision sensor when LED is set to manual mode. More...
 
bool getLedColor (uint8_t *red, uint8_t *green, uint8_t *blue)
 Gets the color of the LED from the vision sensor. More...
 
bool setWifiMode (wifiMode mode)
 
wifiMode getWifiMode (void)
 
- Public Member Functions inherited from vex::device
 device ()
 
 device (int32_t index)
 
 ~device ()
 
V5_DeviceType type ()
 
void init (int32_t index)
 

Public Attributes

int32_t objectCount
 The ammount of objects found in the data sample. More...
 
object largestObject
 The largest object found in the data sample. More...
 
safearray< object, VISION_MAX_OBJECTSobjects
 An array containing the largest object(s) found in the data sample. More...
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 

Detailed Description

Use this class when programming the vision sensor.

The vision sensor has a resolution of 316x212 pixels

Member Enumeration Documentation

◆ detectionMode

Enumerator
objectDetect 
mixedDetect 
lineDetect 
test 

◆ whiteBalanceMode

Enumerator
automatic 
start 
manual 

◆ ledMode

enum vex::vision::ledMode
strong
Enumerator
automatic 
manual 

◆ wifiMode

enum vex::vision::wifiMode
strong
Enumerator
off 
on 

Constructor & Destructor Documentation

◆ vision() [1/2]

vex::vision::vision ( int32_t  index)

Creates a new vision object on the port specified.

Parameters
indexThe port index for this vision. The index is zero-based.

◆ ~vision()

vex::vision::~vision ( )

◆ vision() [2/2]

template<typename... Args>
vex::vision::vision ( int32_t  index,
uint8_t  bright,
Args...  sigs 
)
inline

Creates a new vision object on the port specified. Sets the brightness setting and all of the vision objects settings.

Parameters
indexThe port index for this vision. The index is zero-based.
brightThe vision sensor brightness setting. Values are 0 to 255
sigsList of signature objects used to setup the detection signatures for this sensor.

Member Function Documentation

◆ installed()

bool vex::vision::installed ( )
virtual

Reimplemented from vex::device.

◆ value()

int32_t vex::vision::value ( )
virtual

Reimplemented from vex::device.

◆ takeSnapshot() [1/6]

int32_t vex::vision::takeSnapshot ( uint32_t  id)

Takes a data sample from the vision sensor.

Returns
Returns the number of objects found from the ID passed in the parameter.
Parameters
idThe ID of the object to look for.

◆ takeSnapshot() [2/6]

int32_t vex::vision::takeSnapshot ( code cc)

Takes a data sample from the vision sensor.

Returns
Returns the number of objects found from the code signature passed in the parameter.
Parameters
ccThe code signature of the object to look for.

◆ takeSnapshot() [3/6]

int32_t vex::vision::takeSnapshot ( signature sig)

Takes a data sample from the vision sensor.

Returns
Returns a number of objects found from the signature passed in the parameter.
Parameters
sigThe signature of the object to look for.

◆ takeSnapshot() [4/6]

int32_t vex::vision::takeSnapshot ( uint32_t  id,
uint32_t  count 
)

Takes a data sample from the vision sensor, and only stores the largest samples of the specified amount.

Returns
Returns a limited number of objects found from the ID passed in the parameter.
Parameters
idThe ID of the object to look for.
countthe amount of objects to look for. The largest of the object will be returned.

◆ takeSnapshot() [5/6]

int32_t vex::vision::takeSnapshot ( code cc,
uint32_t  count 
)

Takes a data sample from the vision sensor, and only stores the largest samples of the specified amount.

Returns
Returns a limited number of objects found from the code signature passed in the parameter.
Parameters
ccThe code signature of the object to look for.
countthe amount of objects to look for. The largest of the object will be returned.

◆ takeSnapshot() [6/6]

int32_t vex::vision::takeSnapshot ( signature sig,
uint32_t  count 
)

Takes a data sample from the vision sensor, and only stores the largest samples of the specified amount.

Returns
Returns a limited number of objects found from the signature passed in the parameter.
Parameters
sigThe signature of the object to look for.
countthe amount of objects to look for. The largest of the object will be returned.

◆ setSignature() [1/2]

bool vex::vision::setSignature ( V5_DeviceVisionSignature *  pSignature)

◆ getSignature() [1/2]

bool vex::vision::getSignature ( uint32_t  id,
V5_DeviceVisionSignature *  pSignature 
)

◆ setSignature() [2/2]

bool vex::vision::setSignature ( signature sig)

◆ getSignature() [2/2]

bool vex::vision::getSignature ( uint32_t  id,
signature sig 
)

◆ setMode()

bool vex::vision::setMode ( detectionMode  mode)

◆ getMode()

detectionMode vex::vision::getMode ( void  )

◆ setBrightness()

bool vex::vision::setBrightness ( uint8_t  value)

◆ getBrightness()

uint8_t vex::vision::getBrightness ( void  )

◆ setWhiteBalanceMode()

bool vex::vision::setWhiteBalanceMode ( whiteBalanceMode  mode)

◆ getWhiteBalanceMode()

whiteBalanceMode vex::vision::getWhiteBalanceMode ( void  )

◆ setWhiteBalanceValues()

bool vex::vision::setWhiteBalanceValues ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

◆ getWhiteBalanceValues()

bool vex::vision::getWhiteBalanceValues ( uint8_t *  red,
uint8_t *  green,
uint8_t *  blue 
)

◆ setLedMode()

bool vex::vision::setLedMode ( ledMode  mode)

Changes the mode of the LED on the vision sensor.

Parameters
modeThe LED mode. Automatic mode will cause the LED color to be controlled by the vision sensor firmware. Manual mode allows the LED color to be controlled by the user program.
Returns
Returns true if setting was successfully saved.

◆ getLedMode()

ledMode vex::vision::getLedMode ( void  )

Gets the mode of the LED from the vision sensor.

Returns
Returns a tLedMode that represents the current mode of the vision sensor LED.

◆ setLedBrightness()

bool vex::vision::setLedBrightness ( uint8_t  percent)

Changes the brightness of the LED on the vision sensor when LED is set to manual mode.

Parameters
percentA percentage of total brightness of the vision sensor LED when in manual mode. Values are 0 to 100. 0 = LED off
Returns
Returns true if setting was successfully saved.

◆ getLedBrightness()

uint8_t vex::vision::getLedBrightness ( void  )

Gets the brightness of the LED from the vision sensor.

Returns
Returns a value between 0 and 100 that represents the current brightness of the vision sensor LED.

◆ setLedColor()

bool vex::vision::setLedColor ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

Changes the color of the LED on the vision sensor when LED is set to manual mode.

Parameters
redA value from 0 to 255 the represents the intensity of the red color of the LED.
greenA value from 0 to 255 the represents the intensity of the green color of the LED.
blueA value from 0 to 255 the represents the intensity of the blue color of the LED.
Returns
Returns true if setting was successfully saved.

◆ getLedColor()

bool vex::vision::getLedColor ( uint8_t *  red,
uint8_t *  green,
uint8_t *  blue 
)

Gets the color of the LED from the vision sensor.

Parameters
redA reference to a value to store the intensity of the red color of the LED.
greenA reference to a value to store the intensity of the green color of the LED.
blueA reference to a value to store the intensity of the blue color of the LED.
Returns
Returns true if values were sucessfully recived.

◆ setWifiMode()

bool vex::vision::setWifiMode ( wifiMode  mode)

◆ getWifiMode()

wifiMode vex::vision::getWifiMode ( void  )

Member Data Documentation

◆ objectCount

int32_t vex::vision::objectCount

The ammount of objects found in the data sample.

◆ largestObject

object vex::vision::largestObject

The largest object found in the data sample.

◆ objects

safearray< object, VISION_MAX_OBJECTS > vex::vision::objects

An array containing the largest object(s) found in the data sample.