forked from aglare-enough/waterSortSolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
53 lines (37 loc) · 1.3 KB
/
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
51
52
53
import os.path
from model import Cups
from solver.solver import Solver
from util import env
from adbConnector import Connector
from openCVParser.parser import Parser
import time
# test data
# 把试管抽象为一个特殊的栈(直接用数组来代替,因为数组就有append pop方法,将数组的尾部作为栈顶即试管顶部)
# 将颜色抽象为数字
if __name__ == '__main__':
# 创建环境变量管理器对象
envmanager = env.EnvManager()
# 初始化环境以及连接
envmanager.init_env()
# 截图
Connector.Connector.screencap()
# 等待adb截图保存 不可删除!!!
time.sleep(2)
# 传入img地址生成图片解析器对象parser
parser = Parser(os.path.abspath(".").replace('\\','/') + Connector.img_path)
# 解析数据
data,pos = parser()
print("[DEBUG] position: ",pos)
print("[DEBUG] data :",data)
cups = Cups.Cups(data)
# 进行求解
Solver.sort(cups)
# 输出求解答案
Solver.output(data)
# click
for action in Solver.res:
print("[DEBUG] ",action," ",pos[action[0]] ," -> ",pos[action[1]])
Connector.Connector.tap(pos[action[0]][0],pos[action[0]][1])
time.sleep(0.9)
Connector.Connector.tap(pos[action[1]][0],pos[action[1]][1])
time.sleep(2.5)