Python 2.x or 3.x, 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)
-
Capture frame from camera
-
Find average BGR value inside calibration box
-
Convert BGR value to HSV value
-
Print average HSV value inside calibration box
-
Create adjustable trackbars for minimum and maximum H, S, and V values
-
Get HSV range from trackbars
-
Capture frame from camera
-
Apply HSV mask
-
Print HSV values in use
-
Create adjustable trackbars for minimum and maximum sqrt(area) values
-
Get area values (square the values from trackbars)
-
Capture frame from camera
-
Apply HSV mask
-
Find and draw contours within area constraints
-
Print area values in use
-
Capture frame from camera
-
Remove everything but specified color in frame
-
Find contour for largest object with the specified color within area constraints
-
Find centroid of that object (ideal position to shoot / drop off gear)
-
Calculate error (pixels) of centroid of object from center of frame
-
Convert error in pixels to real world units
-
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