08 / OpenCV and AprilTags
OpenCV Color and Region Processors
Use image regions, color spaces, and thresholds for game element detection.
08 / OpenCV and AprilTags
Use image regions, color spaces, and thresholds for game element detection.
You will
This lesson is about turning camera images into trustworthy robot decisions. The goal is not to make vision seem magical; it is to show how camera setup, processor output, telemetry, and fallbacks make an autonomous decision safe enough to use.
FTC color pipelines usually convert the image, select regions of interest, calculate averages or masks, and reduce that information to a simple result such as LEFT, CENTER, or RIGHT.
The OpMode should not know every pixel detail. The processor should expose a readable result and enough telemetry/debug drawing to trust that result.
Start with a visible stream and raw telemetry before making decisions. Then add regions, detections, metadata, or pose estimates. Autonomous should receive a simple result and confidence, not a pile of image-processing details.
For this specific lesson, students should first restate the goal in robot terms, then identify the value or behavior they expect to observe, then run the smallest test that proves the idea. The lesson should feel like a guided lab: predict, run, observe, explain, and only then extend.
PropPositionProcessor.java · Java
public enum PropPosition { LEFT, CENTER, RIGHT }
private volatile PropPosition position = PropPosition.CENTER;
public Object processFrame(Mat frame, long captureTimeNanos) {
Imgproc.cvtColor(frame, ycrcb, Imgproc.COLOR_RGB2YCrCb);
double leftScore = Core.mean(ycrcb.submat(leftRect)).val[1];
double centerScore = Core.mean(ycrcb.submat(centerRect)).val[1];
position = leftScore > centerScore ? PropPosition.LEFT : PropPosition.CENTER;
return null;
}
public PropPosition getPosition() {
return position;
}Vision fails through lighting, camera placement, exposure, cable issues, wrong tag assumptions, and thresholds that only worked in the shop. The debugging habit is to show the image, print raw scores or detections, and define a safe fallback when the robot is not confident.
Check your understanding
Why should a processor expose a simple enum result?
0 of 1 answered
References
Finished reading?
You'll move on to “AprilTags and Field Pose” next.