Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
CHNZYX committed Sep 1, 2023
2 parents f596cb8 + 413850a commit 2f8f963
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 10 additions & 5 deletions align_angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
import win32con
import win32gui
import pyuac

from utils.config import config
from utils.log import log


def get_angle(su, safe):
import cv2
su.press("w")
time.sleep(0.5)
su.get_screen()
blue = np.array([234, 191, 4])
# blue = np.array([234, 191, 4])
shape = (int(su.scx * 190), int(su.scx * 190))
local_screen = su.get_local(0.9333, 0.8657, shape)
local_screen[np.sum(np.abs(local_screen - blue), axis=-1) <= 150] = blue
local_screen = su.get_local(0.9333, 0.8657, shape) # 裁剪后得到的小地图
hsv = cv2.cvtColor(local_screen, cv2.COLOR_BGR2HSV) # 转HSV
lower = np.array([93, 90, 60]) # 90 改成120只剩箭头,但是角色移动过的印记会消失
upper = np.array([97, 255, 255])
mask = cv2.inRange(hsv, lower, upper) # 创建掩膜
local_screen = cv2.bitwise_and(local_screen, local_screen, mask=mask)
# local_screen[np.sum(np.abs(local_screen - blue), axis=-1) <= 150] = blue
return su.get_now_direc(local_screen)


Expand All @@ -38,7 +43,7 @@ def main(cnt=10, safe=0, ang=[1,1,3], su=None):
for i in ang:
ang_list = []
for j in range(i):
su.mouse_move(100,fine=3//i)
su.mouse_move(100, fine=3 // i)
time.sleep(0.2)
now_ang = get_angle(su, safe)
sub = lst_ang - now_ang
Expand Down
Binary file modified imgs/loc_arrow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,13 @@ def get_bw_map(self, gs=1, sbl=0):

# 计算小地图中蓝色箭头的角度
def get_now_direc(self, loc_scr):
blue = np.array([234, 191, 4])
# blue = np.array([234, 191, 4])
arrow = self.format_path("loc_arrow")
arrow = cv.imread(arrow)
loc_tp = deepcopy(loc_scr)
loc_tp[np.sum(np.abs(loc_tp - blue), axis=-1) > 0] = [0, 0, 0]
# loc_tp[np.sum(np.abs(loc_tp - blue), axis=-1) > 0] = [0, 0, 0]
mx_acc = 0
ang = 0
ang = 0
for i in range(360):
rt = self.image_rotate(arrow, i)
result = cv.matchTemplate(loc_tp, rt, cv.TM_CCORR_NORMED)
Expand Down

0 comments on commit 2f8f963

Please sign in to comment.