Vision#

Introduction#

The VEX AIR Hornet’s Vision Sensor detects and tracks AprilTags. This allows the Hornet to analyze its surroundings, follow objects, and react based on detected visual data.

Below is a list of all available blocks:

Actions – Control the Vision feed and capture object data.

Settings – Adjust which detected objects are accessed.

Values – Retrieve object presence, classification, and properties.

Actions#

get object data#

The get object data block filters data from the Vision Sensor frame. The Vision Sensor can detect AprilTags.

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

The Get object data stack block.#
  get [all AprilTags v] data from Vision [forward v] camera

Parameter

Description

signature

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

  • AprilTag ID 0-37

Note: AprilTags 5 through 37 can be obtained by using the printed AprilTags from AIM Printables.

Example

Example coming soon!

Settings#

set Vision object item#

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

The Set AI Vision object item stack block.#
  set Vision object item to [1]

Parameters

Description

item

The number of the item in the dataset to use.

Example

Example coming soon!

Values#

Vision object exists?#

The Vision object exists? block reports if the Vision Sensor currently detects any objects. This block returns a Boolean value:

  • True – The Vision Sensor detects an object.

  • False – The Vision Sensor does not detect an object.

Note: The get data block returns an empty list if no objects are detected, so if no objects exist, interacting with the empty list of Vision Objects will result in an error.

Theshow or hide AI Vision dashboard stack block.#
  <Vision object exists?>

Parameter

Description

This block has no parameters.

Example

Example coming soon!

Vision object type is?#

The Vision object type is? block reports if the item in the dataset is a specific object type. This block returns a Boolean value.

  • True – The item in the dataset is the specific object type.

  • False – The item in the dataset is not the specific object type.

The AI Vision AI Classification is object Boolean block.#
  <Vision object type is [all AprilTags v] ?>

Parameter

Description

object

Which object to compare the item to:

  • all AprilTags

Example

Example coming soon!

Vision object is AprilTag ID#

The Vision object is AprilTag ID? block reports if the AprilTag is a specific ID number. This block returns a Boolean value:

  • True – The AprilTag ID is the number.

  • False – The AprilTag ID is not the number.

The AI Vision detected AprilTag is Boolean block.#
  <Vision object is AprilTag [1]>

Parameters

Description

AprilTag number

The number to compare against the detected AprilTag’s ID number from 0 to 37.

Example

Example coming soon!

Vision object count#

The Vision object count block returns the amount of detected objects in the dataset.

The Set AI Vision object item stack block.#
  (Vision object count)

Parameters

Description

This block has no parameters.

Example

Example coming soon!

Vision object property#

There are nine properties that are included with each object (shown below) stored after the get object data block is used.

The AI Vision object property reporter block.#
  (Vision 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 Get object data block was used. The Vision Sensor has a resolution of 240 by 320 pixels.

Parameter

Description

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 320.

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

Example

Example coming soon!

height#

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

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

Example

Example coming soon!

centerX#

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

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

Example

Example coming soon!

centerY#

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

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

Example

Example coming soon!

bearing#

bearing reports how far an object is to the left or right of the center of the Vision Sensor’s view as a degree. A value of 0 means it’s centered, positive values mean the object is to the right, and negative values mean the object is to the left.

The AI Vision object property stack block with its parameter set to centerY.#
  (Vision object [bearing v])

Example

Example coming soon!

angle#

Documentation Coming Soon

rotation#

rotation returns the orientation of the detected AprilTag as an integer in degrees from 0 to 359.

The AI Vision object property stack block with its parameter set to rotation.#
  (Vision object [rotation v])

Example

Example coming soon!

originX#

originX returns the x-coordinate of the top-left corner of the detected object’s bounding box in pixels as an integer from 0 to 320.

The AI Vision object property stack block with its parameter set to originX.#
  (Vision object [originX v])

Example

Example coming soon!

originY#

originY returns the y-coordinate of the top-left corner of the detected object’s bounding box in pixels as an integer from 0 to 240.

The AI Vision object property stack block with its parameter set to originY.#
  (Vision object [originY v])

Example

Example coming soon!

id#

id returns the identification number of the detected AprilTag as an integer.

The AI Vision object property stack block with its parameter set to tagID.#
  (Vision object [id v])

Example

Example coming soon!

score#

score returns the confidence score of the detected AI Classification as an integer from 1 to 100, representing a percentage.

The AI Vision object property stack block with its parameter set to tagID.#
  (Vision object [score v])

Example

Example coming soon!

type#

type returns the returns what type of object is detected. It will return the following:

Object Type

Included Objects

AiVision.TAG_OBJECT

AprilTags

The AI Vision object property stack block with its parameter set to tagID.#
  (Vision object [type v])

Example

Example coming soon!