Lesson 26: Camera Processing
Camera processing lets the robot use images to make decisions. Common FRC uses include finding reflective tape, estimating alignment, and helping drivers see parts of the field.
Driver Camera Versus Vision Processing
A driver camera sends video to the driver. Vision processing turns an image into numbers the robot can use. Those are different goals, and they may use different cameras or settings.
The Basic Pipeline
- Capture an image from the camera.
- Filter the image to find the target color or brightness.
- Find shapes or contours in the filtered image.
- Choose the contour that is most likely to be the target.
- Return a simple number, such as horizontal offset from center.
Keep Robot Code Simple
Do not make the drive code depend on a whole image. The drive code usually only needs a few values: whether a target exists, how far left or right it is, and maybe how large it appears.
if (visionHasTarget) {
double correction = visionXOffset * 0.02;
leftMotor.set(-correction);
rightMotor.set(correction);
}Lighting and Testing
Vision code that works in the shop may fail on the field. Lighting changes, camera exposure changes, and other robots can appear in the image. Test in as many real conditions as you can.
Practice
Write down the three numbers your robot would need from a vision system for an aiming task. Then decide what your robot should do when no target is found.