Vision Sensor#

Introduction#

The Vision Sensor for VEX V5 detects and tracks colors and color codes. This allows the Vision Sensor to analyze its surroundings, follow objects, and react based on detected visual data.

Below is a list of all available blocks:

Actions – Capture data from the Vision Sensor for a selected signature.

Settings – Choose which object to interact with.

Values – Access and use the captured data.

Actions#

take Vision Sensor snapshot#

The take Vision Sensor snapshot block filters data from the Vision Sensor frame. The Vision Sensor can detect signatures that include configured colors and color codes.

Colors and color codes must be configured first in the Vision Utility before they can be used with this block.

The dataset stores objects ordered from largest to smallest by width, starting at item 1. Each object’s properties can be accessed using Vision object property block. An empty dataset is returned if no matching objects are detected.

  take a [Vision1 v] snapshot of [SELECT_A_SIG v]

Parameter

Description

device

Which Vision Sensor to use, configured in the Devices window.

signature

The color signature or color code to analyze in the snapshot.

Settings#

set Vision Sensor object item#

The set Vision Sensor object item block sets which item in the dataset to use.

  set [Vision1 v] object item to (1)

Parameter

Description

device

Which Vision Sensor to use, configured in the Devices window.

item

The number of the item in the dataset to use.

Values#

Vision Sensor object exists?#

The Vision Sensor object exists? block returns a Boolean indicating whether any object is detected in the dataset.

  • True – The dataset includes a detected object.

  • False – The dataset does not include any detected objects.

  <[Vision1 v] object exists?>

Parameter

Description

device

Which Vision Sensor to use, configured in the Devices window.

Vision Sensor object count#

The Vision Sensor object count block returns the number of detected objects in the dataset as an integer.

  ([Vision1 v] object count)

Parameter

Description

device

Which Vision Sensor to use, configured in the Devices window.

Vision Sensor object property#

There are five properties that are included with each object (shown below) stored after the take Vision Sensor snapshot block is used.

  ([Vision1 v] object [width v])

Some property values are based off of the detected object’s position in the Vision Sensor’s view at the time that the take Vision Sensor snapshot block was used. The Vision Sensor has a resolution of 316 by 212 pixels.

Parameter

Description

device

Which Vision Sensor to use, configured in the Devices window.

property

Which property of the detected object to use:

width#

width returns the width of the detected object in pixels as an integer from 1 to 316.

  ([Vision1 v] object [width v])

height#

height returns the height of the detected object in pixels as an integer from 1 to 212.

  ([Vision1 v] object [height v])

centerX#

centerX returns the x-coordinate of the center of the detected object in pixels as an integer from 0 to 316.

  ([Vision1 v] object [centerX v])

centerY#

centerY returns the y-coordinate of the center of the detected object in pixels as an integer from 0 to 212.

  ([Vision1 v] object [centerY v])

angle#

angle returns the orientation of the detected Color Code as an integer in degrees from 0 to 180.

  ([Vision1 v] object [angle v])