-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.py
45 lines (34 loc) · 1008 Bytes
/
App.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
33
34
35
36
37
38
39
40
41
42
43
44
45
#Credit to team 2996 Cougars Gone Wired
import numpy as np
import cv2 as cv
import cameraServer
import Pipeline as pipeline
import NTInstance as networkTables
if __name__ == "__main__":
run = True
camera = cv.VideoCapture(0)
if not camera.isOpened():
print("camera failed to open")
run = False
areaPub, xPub, yPub = networkTables.init_vision_table()
output = cameraServer.start_cameraServer()
while run:
ret, src = camera.read()
if not ret:
print("Bad frame... ending")
break
try:
areas, centers = pipeline.run_pipeline(src)
areaPub.set(areas)
xs = [i[0] for i in centers]
ys = [i[1] for i in centers]
xPub.set(xs)
yPub.set(ys)
output.putFrame(src)
except:
print("code don't work")
key = cv.waitKey(1)
if key == ord('q'):
break
cv.destroyAllWindows()
camera.release()