OpenCV Color and Region Processors
Turn pixels into LEFT/CENTER/RIGHT decisions.
Turn pixels into LEFT/CENTER/RIGHT decisions.
In this lesson, you will:
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.
The camera sees pixels; the robot needs a plan. Regions of interest are the bridge between raw image data and a field-specific decision.
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;
}Thresholds fail under lighting changes. If a decision is wrong, inspect the image and raw scores before changing autonomous branches.
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
Mark this lesson complete — “AprilTags and Field Pose” is up next.