Python 2.7, NumPy and OpenCV
Raspberry Pi compatible USB camera (Microsoft Lifecam HD-3000 used in this project)
-
Set a small centered rectangle as the calibration box (can change the size in constants)
-
Get frame from camera
-
Find average BGR value inside calibration box
-
Convert BGR value to HSV value
-
Print HSV values for every frame
-
Create adjustable trackbars for H, S, and V values
-
Get HSV range from trackbars
-
Capture frame from camera
-
Apply HSV mask
-
Print HSV values in use
-
Get frame from camera
-
Remove everything but specified color in frame
-
Find contour for the largest object with the specified color (closest goal)
-
Find centroid of that object (ideal position to shoot / drop off gear)
-
Calculate error and converts from pixels to degrees
-
If the center of the camera is aligned with the center x-axis of the object (goal), then it is ready to shoot
-
Send data over NetworkTables and print in terminal.
Testing has been done with
-
example images provided by WPILIB (2017 images included in this project under sample images)
- Tests for all example images in the boiler folder successful except for images 7 and 32
-
custom made high goal / boiler / gear peg with green highlighter / marker