WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • VisionPortal Camera Setup
  • OpenCV Color and Region Processors
  • AprilTags and Field Pose
  • Vision Fallbacks and Confidence

OpenCV Color and Region Processors

Turn pixels into LEFT/CENTER/RIGHT decisions.

Module 11: Vision and AprilTagsVision

In this lesson, you will:

  1. 01Choose a color space.
  2. 02Measure regions.
  3. 03Expose a simple enum.

Concept narrative

A color pipeline reduces an image to a decision. The processor can know about rectangles and channels, but autonomous should receive a simple result and confidence.

Robot mental model

The camera sees pixels; the robot needs a plan. Regions of interest are the bridge between raw image data and a field-specific decision.

Implementation walkthrough

Convert color space, crop regions, calculate scores, draw rectangles, and expose getPosition. Print raw scores before thresholding.

PropProcessor.javaJava

double leftScore = Core.mean(ycrcb.submat(leftRect)).val[1];
double centerScore = Core.mean(ycrcb.submat(centerRect)).val[1];
double rightScore = Core.mean(ycrcb.submat(rightRect)).val[1];

double best = Math.max(leftScore, Math.max(centerScore, rightScore));
double second = leftScore + centerScore + rightScore - best
    - Math.min(leftScore, Math.min(centerScore, rightScore));

if (best - second < minimumMargin) {
    position = PropPosition.UNKNOWN;
} else if (best == leftScore) {
    position = PropPosition.LEFT;
} else if (best == centerScore) {
    position = PropPosition.CENTER;
} else {
    position = PropPosition.RIGHT;
}

Common mistakes and debugging

Thresholds fail under lighting changes. If a decision is wrong, inspect the image and raw scores before changing autonomous branches.

Practice

Build a two-region detector and test it under at least two lighting conditions.

Checkpoint

  • LEFT, CENTER, and RIGHT regions are drawn and scored.
  • Raw scores and the winning margin are visible.
  • Low-margin frames return UNKNOWN instead of a confident branch.
  • The test record includes the setup, prediction, and observed result.
  • A teammate can repeat the check from the saved evidence without guessing.

Reflection check

Check your understanding before moving on.

Which result best demonstrates completion of “OpenCV Color and Region Processors”?

Why record the test setup, prediction, and observed result?

0 of 2 answered

References

FTC VisionPortal DocsOfficial FTC camera and processor lifecycle documentation.GM0 Computer VisionFTC-oriented vision concepts, pipelines, and practical advice.FTC AprilTag DocsOfficial AprilTag detection and metadata reference.

Finished reading?

Mark this lesson complete — “AprilTags and Field Pose” is up next.

VisionPortal Camera SetupAprilTags and Field Pose