-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ | |
|
||
- [x] 无用的功能 | ||
----- | ||
## v1.82 | ||
|
||
- 使用新算法检测经验数字坐标,移除固定坐标 | ||
|
||
## v1.81 | ||
|
||
- fix bugs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes