Vision Sensor#

Introduction#

The Vision Sensor for VEX EXP 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 object type.

Settings — Choose which object to interact with.

Values — Access and use the captured data.

Actions#

take Vision Sensor snapshot#

The take vision snapshot stack block will capture the current image from the Vision Sensor to be processed and analyzed for color signatures or color codes.

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

Note: A snapshot is required first before using any other Vision Sensor blocks.

The dataset stores objects ordered from largest to smallest by width, starting at index 0. Each object’s properties can be accessed using the vision object property block. An empty dataset is reported if no matching objects are detected.

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

Parameter

Description

device

Which Vision Sensor to use.

signature

Filters the dataset to only include data of the given signature. Available signatures are:

  • NAME - A color signature or color code where NAME is the name configured in the Vision Sensor Utility

Settings#

set Vision Sensor object item#

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

  set [Vision1 v] object item to (1)

Parameter

Description

device

Which Vision Sensor to use.

item

The number of the item in the dataset to use.

Values#

Vision Sensor object exists#

The vision object exists Boolean block reports whether a specified color signature or color code is detected in the dataset.

  • True — The dataset includes a color signature or color code.

  • False — The dataset does not include a color signature or color code.

  <[Vision1 v] object exists?>

Parameter

Description

device

Which Vision Sensor to use.

Vision Sensor object count#

The vision object count reporter block reports the number of detected objects in the dataset as a whole number.

  ([Vision1 v] object count)

Parameter

Description

device

Which Vision Sensor to use.

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])

All property values describe the detected object’s position and size in the Vision Sensor’s view at the moment the take Vision Sensor snapshot block was used. These values are measured in pixels, based on the sensor’s 316 by 212 pixel resolution.

Parameter

Description

vision sensor

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

property

Which property of the detected object to use:

width#

The width property reports the width of the detected color signature in pixels as a whole number from 0 to 316.

The Vision object property stack block with its parameter set to width.#
  [Vision1 v] object [width v]

height#

The height property reports the height of the detected color signature in pixels as a whole number from 0 to 212.

The Vision object property stack block with its parameter set to height.#
  [Vision1 v] object [height v]

centerX#

The centerX property reports the x-coordinate of the center of the detected color signature in pixels as a whole number from 0 to 316.

The Vision object property stack block with its parameter set to centerX.#
  [Vision1 v] object [centerX v]

centerY#

The centerY property reports the y-coordinate of the center of the detected color signature in pixels as a whole number from 0 to 212.

The Vision object property stack block with its parameter set to centerY.#
  [Vision1 v] object [centerY v]

angle#

The angle property reports the orientation of the detected color code as a whole number in degrees from 0 to 180.

Note: The angle property can only be used with color codes.

The Vision object property stack block with its parameter set to angle.#
  [Vision1 v] object [angle v]