-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjump.py
More file actions
43 lines (43 loc) · 1.69 KB
/
jump.py
File metadata and controls
43 lines (43 loc) · 1.69 KB
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
from cv2 import cv2
import functions
while True:
b, g, r, img = functions.GetScreenshot()
threshold_flag = 0
while threshold_flag != 5:
if threshold_flag == 0:
Screen_shot = b
elif threshold_flag == 1:
Screen_shot = r
cv2.imwrite('r.png', r)
elif threshold_flag == 2:
Screen_shot = g
elif threshold_flag == 3:
Screen_shot = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
else:
Screen_shot = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
Screen_shot = cv2.equalizeHist(Screen_shot)
edges = functions.PreProcess(Screen_shot)
temp1Name = 'temp1.png'
dollLoc = functions.LocateDollandMiniCircle(edges, temp1Name)
temp2Name = 'temp3.png'
MiniLoc = functions.LocateDollandMiniCircle(edges, temp2Name)
h = abs(MiniLoc[1] - dollLoc[1])
w = abs(MiniLoc[0] - dollLoc[0])
if abs((w + 0.00000001) / h - 3 ** 0.5) <= 0.1:
jmp_length3 = 2 * h - 8
else:
jmp_length3 = 0
jmp_length1 = functions.LocateRectangle(edges, dollLoc)
jmp_length2 = functions.LocateCircles(edges, dollLoc)
jmp_length = max(jmp_length1, jmp_length2, jmp_length3)
print(jmp_length1, jmp_length2, jmp_length3)
#edges = functions.MakeCircles(jmp_length1,edges,dollLoc)
#edges = functions.MakeCircles(jmp_length2, edges, dollLoc)
#edges = functions.MakeCircles(jmp_length3, edges, dollLoc)
#cv2.imshow('',edges)
print(jmp_length)
if jmp_length != 0:
functions.MakeJmpAction(jmp_length)
break
else:
threshold_flag = (threshold_flag+1)