Working with Contours¶
After thresholding and removing noise with morphological operations, you are now ready to use OpenCV’s
findContours method. This method allows you to generate contours based on your binary image.
Finding and Filtering Contours¶
In cases where there is only one vision target, you can just take the largest contour and assume that that is the target you are looking for. When there is more than one vision target, you can use size, shape, fullness, and other properties to filter unwanted contours out.
If you draw the contour you just found, it should look something like this:
Extracting Information from Contours¶
Now that you’ve found the contour(s) that you want, you now want to get information about it, such as the center, corners, and rotation.
Publishing to NetworkTables¶
You can use NetworkTables to send these properties to the Driver Station and the RoboRIO. Additional processing could be done on the Raspberry Pi, or the RoboRIO itself.