Space Academy 3.0 is open — want to become a project contributor?Join in

Programming

OpenCV Vision

Building an EasyOpenCV pipeline for prop and element detection.

1 min readUpdated Jul 22, 2026

Most FTC vision tasks reduce to: convert colour space, threshold, find the largest contour, and decide which zone it falls in. Keep it that simple and it will survive venue lighting.

Pipeline skeletonLink to this section

java
public class PropPipeline extends OpenCvPipeline {
    private final Mat hsv = new Mat();
    private final Mat mask = new Mat();
    public volatile int zone = 2;

    @Override
    public Mat processFrame(Mat input) {
        Imgproc.cvtColor(input, hsv, Imgproc.COLOR_RGB2HSV);
        Core.inRange(hsv, new Scalar(0, 120, 70), new Scalar(10, 255, 255), mask);

        List<MatOfPoint> contours = new ArrayList<>();
        Imgproc.findContours(mask, contours, new Mat(),
                Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);

        double best = 0;
        for (MatOfPoint c : contours) {
            Rect r = Imgproc.boundingRect(c);
            if (r.area() > best && r.area() > 1500) {
                best = r.area();
                zone = r.x < input.width() / 3 ? 1 : r.x < 2 * input.width() / 3 ? 2 : 3;
            }
        }
        return input;
    }
}

Lighting disciplineLink to this section

  • Work in HSV, never RGB — hue survives brightness changes.
  • Record footage at the venue during practice and replay it offline.
  • Reject contours below a minimum area to kill noise.