-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
50 lines (39 loc) · 976 Bytes
/
main.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
46
47
48
49
50
import numpy as np
from pd import track
import time
import math
def main():
#scaling factors
#sfx = 30.0/140.0
#sfy = 30.0/144.0
#scaling factors
sfx = 30.0/152.0
sfy = 30.0/152.0
tfx = 68
tfy = 60
y_off = 2/sfy
ball = np.array([])
robot1 = np.array([])
robot2 = np.array([])
for i in range(100):
ball = track.video(1,'red')
#print(ball)
print(str(int(sfx*(ball[0]-tfx)))+','+str(int(sfy*(ball[1]-tfy))))
#ball = track.video(1,'red')
#print(ball)
#print(str(int(sfx*(ball[0]-tfx)))+','+str(int(sfy*(ball[1]-tfy))))
'''
#get ball's position
#(x,y,w,h)
ball = track.video(1, 'red')
#print(ball)
print(sfx*ball[0], sfy*ball[1], sfx*ball[2], sfy*ball[3])
time.sleep(5)
#get ball's position
#(x,y,w,h)
ball = track.video(1, 'red')
#print(ball)
print(sfx*ball[0], sfy*ball[1], sfx*ball[2], sfy*ball[3])
'''
if __name__=='__main__':
main()