-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathControlPanel.py
32 lines (28 loc) · 1.19 KB
/
ControlPanel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import cv2, math
from VisionUtilities import *
# Finds the balls from the masked image and displays them on original stream + network tables
def findControlPanel(frame, mask):
# Finds contours
if is_cv3:
_, contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_TC89_KCOS)
else:
contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_TC89_KCOS)
# Take each frame
# Gets the shape of video
screenHeight, screenWidth, _ = frame.shape
# Gets center of height and width
centerX = (screenWidth / 2) - .5
centerY = (screenHeight / 2) - .5
# Copies frame and stores it in image
image = frame.copy()
# Processes the contours, takes in (contours, output_image, (centerOfImage)
if len(contours) != 0:
image = findControlPanelColour(contours, image, centerX, centerY)
# Shows the contours overlayed on the original video
return image
# Draws Contours and finds the colour the control panel wheel is resting at
# centerX is center x coordinate of image
# centerY is center y coordinate of image
def findControlPanelColour(contours, image, centerX, centerY):
#ToDo, Add code to publish wheel colour
return image