-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathini_api.py
53 lines (42 loc) · 2.22 KB
/
ini_api.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
51
52
53
import configparser
import numpy as np
class API():
def __init__(self):
#class parameters
self.config = configparser.ConfigParser()
self.config.read('config.ini')
self.pts0 = np.array([(0,0),(0,0),(0,0),(0,0)])
self.pts1 = np.array([(0,0),(0,0),(0,0),(0,0)])
self.pts2 = np.array([(0,0),(0,0),(0,0),(0,0)])
self.points = [[0, 0], [0, 0]]
#filling the parameters
self.read_stadium_points()
self.read_crop_points()
#reading from the ini file
def read_stadium_points(self):
self.pts0[0] = tuple(map(int, self.config['stadium']['first_player_point_1'].split(',')))
self.pts0[1] = tuple(map(int, self.config['stadium']['first_player_point_2'].split(',')))
self.pts0[2] = tuple(map(int, self.config['stadium']['first_player_point_3'].split(',')))
self.pts0[3] = tuple(map(int, self.config['stadium']['first_player_point_4'].split(',')))
self.pts1[0] = tuple(map(int, self.config['stadium']['second_player_point_1'].split(',')))
self.pts1[1] = tuple(map(int, self.config['stadium']['second_player_point_2'].split(',')))
self.pts1[2] = tuple(map(int, self.config['stadium']['second_player_point_3'].split(',')))
self.pts1[3] = tuple(map(int, self.config['stadium']['second_player_point_4'].split(',')))
self.pts2[0] = tuple(map(int, self.config['stadium']['net_point_1'].split(',')))
self.pts2[1] = tuple(map(int, self.config['stadium']['net_point_2'].split(',')))
self.pts2[2] = tuple(map(int, self.config['stadium']['net_point_3'].split(',')))
self.pts2[3] = tuple(map(int, self.config['stadium']['net_point_4'].split(',')))
def read_crop_points(self):
self.points[0][1] = int(self.config['crop']['crop_point_01'])
self.points[1][1] = int(self.config['crop']['crop_point_11'])
self.points[0][0] = int(self.config['crop']['crop_point_00'])
self.points[1][0] = int(self.config['crop']['crop_point_10'])
#helpers
def get_stadium_points(self):
return self.pts0,self.pts1,self.pts2
def get_crop_points(self):
return self.points
crop_point_01 = 321
crop_point_11 = 711
crop_point_00 = 329
crop_point_10 = 1559