FRC Vision using OpenCV Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample_images
src
tests
.gitignore
License.md
README.md

README.md

NerdyVision

FRC Vision Processing using OpenCV Python

What You Need

Python 2.x or 3.x, NumPy and OpenCV

PyNetworkTables

MJPG streamer

Raspberry Pi compatible USB camera (Microsoft Lifecam HD-3000 used in this project)

Food

Calibration Mode 1

  1. Set a small centered rectangle as the calibration box (can change the size)

  2. Capture frame from camera

  3. Find average BGR value inside calibration box

  4. Convert BGR value to HSV value

  5. Print average HSV value inside calibration box

Calibration Mode 2

  1. Create adjustable trackbars for minimum and maximum H, S, and V values

  2. Get HSV range from trackbars

  3. Capture frame from camera

  4. Apply HSV mask

  5. Print HSV values in use

Calibration Mode 3

  1. Create adjustable trackbars for minimum and maximum sqrt(area) values

  2. Get area values (square the values from trackbars)

  3. Capture frame from camera

  4. Apply HSV mask

  5. Find and draw contours within area constraints

  6. Print area values in use

Tracking Mode

  1. Capture frame from camera

  2. Remove everything but specified color in frame

  3. Find contour for largest object with the specified color within area constraints

  4. Find centroid of that object (ideal position to shoot / drop off gear)

  5. Calculate error (pixels) of centroid of object from center of frame

  6. Convert error in pixels to real world units

  7. Send data over NetworkTables and print in terminal

Testing

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