Skip to content

Commit

Permalink
v1.82
Browse files Browse the repository at this point in the history
  • Loading branch information
AprDeci committed Oct 5, 2023
1 parent 67c4d23 commit 3ed2249
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ AnimalParty.spec
Ui/__pycache__/
imgs/nums
imgs/num
PaddleOCR-json_v.1.3.0
PaddleOCR-json_v.1.3.0
testrecources
38 changes: 38 additions & 0 deletions PickExpnumber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import cv2
import numpy as np
tolerancex,tolerancey = 20,20
explocation = {
"room": (1500, 400, 300, 200),
"quickgame": (1500, 200, 300, 200),
}
def getAllExp(bounding_rects):
sorted_arr = bounding_rects[bounding_rects[:, 1].argsort()]
return sorted_arr[0]
# 加载图像
def getExpimg(path,model):
image_path = cv2.imread(path)
if model == 'room':
region_x, region_y, region_w, region_h = explocation["room"]
else:
region_x, region_y, region_w, region_h = explocation["quickgame"]
image = image_path[region_y:region_y+region_h, region_x:region_x+region_w]
lower_color = np.array([42,180,140])
upper_color = np.array([45, 200, 150])
mask = cv2.inRange(image, lower_color, upper_color)
# 形态学操作
kernel = np.ones((10, 10), np.uint8)
erosion = cv2.erode(mask, kernel, iterations=1)
mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)
# 查找轮廓
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE,)
# 处理每个轮廓
bounding_rects = []
for contour in contours:
x, y, w, h = cv2.boundingRect(contour)
bounding_rects.append([x+region_x,y+region_y,w,h])
bounding_rects = np.array(bounding_rects)
result = getAllExp(bounding_rects)
rectangle_x,rectangle_y,rectangle_w,rectangle_h = result[0]-tolerancex,result[1]-tolerancey,result[2]+tolerancex+10,result[3]+tolerancey+10
exp_pic = image_path[rectangle_y:rectangle_y+rectangle_h,rectangle_x:rectangle_x+rectangle_w]
cv2.imwrite('./imgs/exp.png',exp_pic)
getExpimg('./testrecources/expjs.png','room')
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

- [x] 无用的功能
-----
## v1.82

- 使用新算法检测经验数字坐标,移除固定坐标

## v1.81

- fix bugs
Expand Down
1 change: 1 addition & 0 deletions Ui/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def setupUi(self, setup):
self.horizontalLayout.addItem(spacerItem)
self.HyperlinkLabel = HyperlinkLabel(self.layoutWidget)
self.HyperlinkLabel.setObjectName("HyperlinkLabel")
self.HyperlinkLabel.setUrl('https://ocr.space/')
self.horizontalLayout.addWidget(self.HyperlinkLabel)
self.OK = PrimaryPushButton(setup)
self.OK.setGeometry(QtCore.QRect(270, 210, 153, 32))
Expand Down
Binary file added __pycache__/PickExpnumber.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/controWin_inter.cpython-311.pyc
Binary file not shown.
8 changes: 6 additions & 2 deletions controWin_inter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from qfluentwidgets import FluentIcon as FIF

from circle_detection import isthereCircle
from PickExpnumber import getExpimg

THRESHOLD=0.02

Expand Down Expand Up @@ -167,7 +168,8 @@ def quickgame(self, limit_number, shutdown, game_number):
if self.execute_condition(current_time, 'endgame.png', 5):
avg=self.ifthereimg('./imgs/end.png', '结束游戏')[1]
if avg is not None:
self.get_screenshot(region=(1641,266,70,40))
self.get_screenshot()#获取截图捕获经验
getExpimg('./imgs/screenshot.png','quickgame')
time.sleep(0.3)
pyautogui.leftClick(avg[0],avg[1])
self.action_ready = False
Expand Down Expand Up @@ -231,7 +233,9 @@ def roomgame(self):
self.routine_click('./imgs/expup.png', '升级')
self.routine_click('./imgs/expup2.png', '升级2')
if self.ifthereimg('./imgs/xiangce.png', '结算')[0]:
self.get_screenshot(region=(1645,448,70,40))
self.get_screenshot() # 获取截图捕获经验
getExpimg('./imgs/screenshot.png', 'room')
time.sleep(0.3)
getexp=self.Ocr("./imgs/exp.png")
if getexp == 'error':
continue
Expand Down
Binary file modified imgs/exp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mainGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from Ui.myIcon import myIcon
from setup_inter import setupWin

current_version = 1.81
current_version = 1.82
class mainwindow(SplitFluentWindow):
def __init__(self):
super().__init__()
Expand Down
File renamed without changes

0 comments on commit 3ed2249

Please sign in to comment.