VisionPortal
Use the FTC SDK's VisionPortal framework to work with cameras and vision processors.
VisionPortal is the FTC SDK's framework for managing cameras and vision processing.
It provides a common interface for connecting a camera to vision processors such as the AprilTag processor.
A simplified VisionPortal setup looks like:
Camera
↓
VisionPortal
↓
Vision Processor
↓
Detection Data
↓
Robot CodeCameras
VisionPortal can work with cameras connected to the Robot Controller.
The most common setup is a USB webcam connected to a Control Hub or Robot Controller.
The camera provides a stream of images to VisionPortal, which passes those images to the configured vision processors.
For example:
WebcamName webcam = hardwareMap.get(
WebcamName.class,
"Webcam 1"
);The name must match the camera's configuration in the FTC Robot Controller.
Vision processors
VisionPortal does not decide what is in an image by itself.
Instead, it manages one or more vision processors.
A processor receives camera frames and extracts useful information from them.
For example:
Camera
↓
VisionPortal
├── AprilTag Processor
└── Other ProcessorThe AprilTag processor looks for AprilTags and produces AprilTag detections.
Creating a processor
The FTC SDK provides an AprilTag processor that can be created with default settings:
AprilTagProcessor aprilTagProcessor =
AprilTagProcessor.easyCreateWithDefaults();For more control, you can use the builder.
Creating VisionPortal
After creating the processor, create a VisionPortal and provide it with the camera and processor:
VisionPortal visionPortal = new VisionPortal.Builder()
.setCamera(webcam)
.addProcessor(aprilTagProcessor)
.build();The processor will now receive frames from the camera.
Getting detections
Once the processor is running, your code can retrieve its detections:
List<AprilTagDetection> detections =
aprilTagProcessor.getDetections();You can then examine each detection:
for (AprilTagDetection detection : detections) {
telemetry.addData("Tag ID", detection.id);
}Because a camera can see multiple tags at once, the processor returns a list of detections.
Multiple processors
VisionPortal can manage multiple processors.
Conceptually:
Camera
↓
VisionPortal
├── AprilTag Processor
├── Object Detector
└── Custom ProcessorThis allows multiple types of vision processing to use the same camera stream.
However, additional processing can increase the computational workload. Only run the processors you actually need.
Camera controls
VisionPortal also provides access to camera controls such as:
- Exposure
- Gain
- Focus
These settings can have a significant effect on detection quality.
For example, if an AprilTag is difficult to detect in a dark environment, adjusting the camera exposure may improve the image.
Before changing your vision algorithm, make sure your camera is producing a usable image.
VisionPortal and OpenCV
VisionPortal can also be used with custom vision processing.
If you need to build your own computer vision pipeline, you can use OpenCV-based processing.
You do not need to understand OpenCV to use the built-in AprilTag processor.
If you want to create custom image-processing algorithms, however, OpenCV becomes important.
See the FTC VisionPortal documentation for detailed API information and advanced configuration.
When should you use VisionPortal?
VisionPortal is a good choice when:
- You want to use AprilTags
- You want to use FTC's built-in vision processors
- You want vision integrated directly into the FTC SDK
- You are building a relatively straightforward vision system
If you need more advanced or custom vision processing, you may want to look into OpenCV or dedicated hardware such as a Limelight.
Was this resource helpful?
