Skip to content

Commit

Permalink
Merge pull request #161 from zjnGitHub/main
Browse files Browse the repository at this point in the history
  • Loading branch information
CHNZYX committed Aug 31, 2023
2 parents f17c5db + 25f3c37 commit 413850a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
17 changes: 11 additions & 6 deletions align_angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@
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)


# 不同电脑鼠标移动速度、放缩比、分辨率等不同,因此需要校准
# 基本逻辑:每次转60度,然后计算实际转了几度,计算出误差比
def main(cnt=10, safe=0, ang=[1,1,3], su=None):
def main(cnt=10, safe=0, ang=[1, 1, 3], su=None):
log.info("开始校准")
if su is None:
from utils.utils import UniverseUtils
Expand All @@ -35,7 +40,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 413850a

Please sign in to comment.