Using the AI Vision Sensor in VEXcode EXP Blocks

Discover the basics of using the AI Vision Sensor with VEXcode EXP Blocks in this beginner-friendly guide, as we walk you through the tools available with the new AI Vision Sensor blocks and demonstrate how to use them in your VEXcode EXP projects.

Make sure you have Color Signatures and Color Codes configured with your AI Vision Sensor so they can be used with your blocks. To learn more about how to configure them, you can read the articles below:

Take Snapshots


Using the Take snapshot block is crucial when coding with your AI Vision Sensor. You need to use this block every time you interact with the sensor, whether you're detecting a color, measuring a Color Signature's size, or identifying a Color Code.

This is important because the sensor relies on the most recent snapshot for its data. If you don't update the snapshot, the sensor will use old information, which can lead to inaccurate results.

Screenshot 2024-03-19 at 10.30.07 AM.png

The AI Vision Sensor also needs to know what Color Signature or Color Code you want it to be focusing on. In this example, it will only detect objects that match its “Blue” Color Signature and nothing else.

Screenshot 2024-03-19 at 10.29.07 AM.png

With these blocks, you take a snapshot and look for anything that matches the “Blue” Color Signatures. Then you tell the AI Vision Sensor to focus on the largest object and then print that object’s width to the VEXcode console.

No matter what, your code should always start with a Take snapshot block right at the beginning. This ensures that the AI Vision Sensor is always using the most current information for any blocks that come after it.

Set Object Item

Whenever you want information about a specific object, you have to use the Set object item block to tell the AI Vision Sensor what it should be looking for.


In this example, we want objects that match the Color Signature “Blue”. We want to get the width of the largest “Blue” object, but since there’s two identified objects, we need to tell the AI Vision Sensor which object we want the width of.

The AI Vision Sensor sorts all the objects that match the last Take snapshot block’s Color Signature from largest to smallest, where the largest object will be the first object and the smallest object becomes the last object.

You can also utilize this feature for precise measurements when approaching objects. For instance, the robot can be programmed to keep moving forward until the detected object reaches a certain width.

Screenshot 2024-03-19 at 10.24.09 AM.png

As the object gets closer to the AI Vision Sensor, its apparent size increases. This allows you to leverage the AI Vision Utility to obtain precise measurements required for your code.

Object Exists

The Object exists block is a Boolean block that will return a True or False if it sees the Color Signature in the last taken snapshot.


Screenshot 2024-03-19 at 10.21.03 AM.png

In this example, the robot will be constantly taking snapshots with the AI Vision Sensor. If it identifies any object with the “Blue” Color Signature, it will drive forward.

If any snapshot does not have the “Blue” Color Signature, the robot will stop moving.

Object Count

Using the Object count block will allow you to see how many objects of a specific Color Signature the AI Vision Sensor can see in its last snapshot. 


Here, we see the AI Vision Sensor has the configured Color Signature “Blue”, and is detecting two of them.

Screenshot 2024-03-19 at 10.16.45 AM.png

In this code, the AI Vision Sensor would take a snapshot and print “2” on the VEXcode console, since it only detects two “Blue” Color Signatures.


The Object block lets you get measurements from any specified object from the AI Vision Sensor’s last snapshot. You can get the measurements (pixel) of the object’s width and height, as well as its Center and Origin coordinates. You can also get the angle of rotation of an object, which is most useful with Color Codes!


Height / Width

How wide or how tall the detected object is in pixels.

Height will return a value between 0 and 240.

Width will return a value between 0 and 320.

CenterX / CenterY

Reports the X or Y coordinate of the center of the detected Color Signature or Color Code.

CenterX will return a number between 0 and 320.

CenterY will return a number between 0 and 240.

OriginX / OriginY

Reports the X or Y coordinate of the top-leftmost corner of the detected color signature or code.

OriginX will return a number between 0 and 320.

OriginY will return a number between 0 and 240.


Reports the angle of the detected color code only, ranging from 0 to 360 degrees.

Note: While reporting Angles of Color Signatures is an option, please be aware that the accuracy of the numbers may fluctuate.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: