Skip to main content

Description

The Vision Sensor allows your robot to collect visual data from a live feed. A live feed is a streaming transmission of what a video camera is capturing. The Vision Sensor is like a smart camera that can observe, select, adjust, and store colors and objects that appear in its visual field.

VEX Vision Sensor with the top of the sensor shown to the left and the bottom of the sensor, with ports for connections shown to the right.
Vision Sensor 276-4850

Capabilities:

  • This sensor can be used for recognizing colors and color patterns.
  • This sensor can be used to follow an object.
  • This sensor can be used to collect information about the environment.

The Vision Sensor allows the robot to use visual input data from its environment. The project can then determine how the visual input data should affect the robot's behavior. For example, the robot could perform actions (output) such as spinning motors or displaying results on the LCD screen.

The Vision Sensor can also capture a snapshot of what is in front of it and analyze it according to what the user is asking. For example, a user can gather data from the snapshot such as, what color is the object? Is there an object detected at all? How large is the object (width and height)?

The robot can then make decisions based off of this data. The partial example project below shows how this is done. Three colors are being checked repeatedly after the project is started, and each color check is a different event. Only the event that checks for Blue is shown below. This stack has the robot print "Blue Object Found" if a blue object is detected or "No Blue Object" otherwise. The check_red and check_green events not shown below have similar stacks for deciding what to print on the screen.

The image shows a VEXcode C++ program for a robot that uses events to check for the presence of blue, red, and green objects using a vision sensor. The program starts by including the necessary VEX library and setting up three events: checkBlue, checkRed, and checkGreen. A function called hasBlueCallback is defined to handle the checkBlue event. This function sets the font and cursor on the robot's screen, clears the previous line, and takes a snapshot using the vision sensor to check for a blue object. If a blue object is found, the message Blue Object Found is printed on the screen; otherwise, the message No Blue Object is displayed. In the main function, the robot's configuration is initialized, and the hasBlueCallback function is registered as the event handler for the checkBlue event. The program then enters an infinite loop where it continuously broadcasts the checkBlue, checkRed, and checkGreen events every second