-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (30 loc) · 908 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
from jump.adb import Adb
from jump.process import jumpmaster
import cv2 as cv
import numpy as np
import math
import time
mx = 0
my = 0
ratio = 0.5
def mouse_val(event,x,y,flags,param):
global mx,my,che_x,che_y,ratio
if event == cv.EVENT_LBUTTONDOWN:
x1 = np.random.randint(550,600)
y1 = np.random.randint(350,550)
time = math.sqrt(abs(che_x - x)**2 + abs(che_y - y)**2)
#print("distance : ",math.sqrt(abs(che_x - x)**2 + abs(che_y - y)**2))
cal_time = int(time*2.2)
adb.touch(x1,y1,cal_time)
if __name__ == "__main__":
adb = Adb()
jmp = jumpmaster()
while True:
img = adb.screenshot() # 发送ADB指令截图
che_x,che_y = jmp.findChess(img)
x,y = jmp.findBox()
jmp.visual()
cv.waitKey(500)
adb.touch(che_x,che_y,x,y)
cv.waitKey(800)
cv.destroyAllWindows()