Vision#

Introduction#

The VEX AIR Drone’s Vision Sensor detects and tracks AprilTag IDs. This allows the drone to analyze its surroundings, follow objects, and react based on detected visual data. Below is a list of all available methods and properties:

Getters – Detect if the drone is holding an object.

  • get_camera_image – Returns an image from the selected camera.

  • get_data – Returns a tuple of detected objects based on a given signature.

Properties – Object data returned from get_data.

  • exists – Whether the object exists in the current detection as a Boolean.

  • width – Width of the detected object in pixels.

  • height – Height of the detected object in pixels.

  • centerX – X position of the object’s center in pixels.

  • centerY – Y position of the object’s center in pixels.

  • bearing – Horizontal angle relative to the front of the drone in degrees.

  • rotation – Orientation of the object in degrees.

  • originX – X position of the object’s top-left corner in pixels.

  • originY – Y position of the object’s top-left corner in pixels.

  • id – Tag ID of the object.

  • score – Confidence score for AI Classifications (1–100).

  • type – Returns the object’s type (AprilTag).

Getters#

get_camera_image#

Documentation Coming Soon

get_data#

get_data filters the data from the Vision Sensor frame to return a tuple. The Vision Sensor can detect AprilTag IDs.

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

Usage:
drone.vision.get_data(camera, signature, count)

Parameters

Description

camera

The camera to retrieve data from:

  • DOWNWARD_CAMERA
  • FORWARD_CAMERA

signature

What signature to get data of. Available signatures are:

  • ALL_TAGS - All AprilTags
  • TAG0 through TAG37 - A single AprilTag with an ID from 0 to 37

count

Optional. Sets the maximum number of objects that can be returned from 1 to 24 (default: 8).

# Example coming soon

Properties#

There are thirteen properties that are included with each object stored in a tuple after the get_data method is used.

Some property values are based off of the detected object’s position in the Vision Sensor’s view at the time that drone.vision.get_data was used. The Vision Sensor has a resolution of 240 by 320 pixels.

.exists#

.exists returns if the index exists in the tuple or not. This property returns a Boolean value. Returns an error if there are no detected objects.

  • True – The index exists.

  • False – The index does not exist.

# Example coming soon

.width#

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

# Example coming soon

.height#

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

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

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

# Example coming soon

.bearing#

.bearing returns 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.

# Example coming soon

.rotation#

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

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

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

# Example coming soon

.id#

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

For an AprilTag, the .id property represents the detected AprilTag’s ID number in the range of 0 to 36.

# Example coming soon

.score#

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

# Example coming soon

.type#

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

Object Type

Included Objects

AiVision.TAG_OBJECT

AprilTag IDs

# Example coming soon