mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-21 21:49:17 +08:00
Merge remote-tracking branch 'origin/master' into data_key_collect
This commit is contained in:
BIN
bin/cnocr_models/jp/cnocr-v1.2.0-densenet-lite-gru-0125.params
Normal file
BIN
bin/cnocr_models/jp/cnocr-v1.2.0-densenet-lite-gru-0125.params
Normal file
Binary file not shown.
1905
bin/cnocr_models/jp/cnocr-v1.2.0-densenet-lite-gru-symbol.json
Normal file
1905
bin/cnocr_models/jp/cnocr-v1.2.0-densenet-lite-gru-symbol.json
Normal file
File diff suppressed because it is too large
Load Diff
3051
bin/cnocr_models/jp/label_cn.txt
Normal file
3051
bin/cnocr_models/jp/label_cn.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,6 @@ echo cnocr: %log_cnocrVer%
|
|||||||
echo gooey: %log_gooeyVer%
|
echo gooey: %log_gooeyVer%
|
||||||
echo colored: %log_coloredVer%
|
echo colored: %log_coloredVer%
|
||||||
echo Python Levenshtein: %log_LevenshteinVer%
|
echo Python Levenshtein: %log_LevenshteinVer%
|
||||||
echo pyocr: %log_pyocrVer%) >> %deploy_log_file%
|
|
||||||
call :Log_common
|
call :Log_common
|
||||||
goto :eof
|
goto :eof
|
||||||
|
|
||||||
@@ -57,7 +56,6 @@ echo mxnet: %log_mxnetVer%
|
|||||||
echo cnocr: %log_cnocrVer%
|
echo cnocr: %log_cnocrVer%
|
||||||
echo gooey: %log_gooeyVer%
|
echo gooey: %log_gooeyVer%
|
||||||
echo colored: %log_coloredVer%
|
echo colored: %log_coloredVer%
|
||||||
echo pyocr: %log_pyocrVer%) >> %deploy_log_file%
|
|
||||||
call :Log_common
|
call :Log_common
|
||||||
goto :eof
|
goto :eof
|
||||||
|
|
||||||
@@ -74,8 +72,6 @@ for /f "tokens=2 delims=-" %%i in ('dir /b "pip*.dist-info"') do ( set "log_pipV
|
|||||||
set "log_pipVer=%log_pipVer:.dist=%"
|
set "log_pipVer=%log_pipVer:.dist=%"
|
||||||
for /f "tokens=2 delims=-" %%i in ('dir /b "adbutils*.dist-info"') do ( set "log_adbutilsVer=%%i" )
|
for /f "tokens=2 delims=-" %%i in ('dir /b "adbutils*.dist-info"') do ( set "log_adbutilsVer=%%i" )
|
||||||
set "log_adbutilsVer=%log_adbutilsVer:.dist=%"
|
set "log_adbutilsVer=%log_adbutilsVer:.dist=%"
|
||||||
for /f "tokens=2 delims=-" %%i in ('dir /b "pyocr*.dist-info"') do ( set "log_pyocrVer=%%i" )
|
|
||||||
set "log_pyocrVer=%log_pyocrVer:.dist=%"
|
|
||||||
for /f "tokens=2 delims=-" %%i in ('dir /b "numpy*.dist-info"') do ( set "log_numpyVer=%%i" )
|
for /f "tokens=2 delims=-" %%i in ('dir /b "numpy*.dist-info"') do ( set "log_numpyVer=%%i" )
|
||||||
set "log_numpyVer=%log_numpyVer:.dist=%"
|
set "log_numpyVer=%log_numpyVer:.dist=%"
|
||||||
for /f "tokens=2 delims=-" %%i in ('dir /b "scipy*.dist-info"') do ( set "log_scipyVer=%%i" )
|
for /f "tokens=2 delims=-" %%i in ('dir /b "scipy*.dist-info"') do ( set "log_scipyVer=%%i" )
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ from module.exception import ScriptError
|
|||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.al_ocr import AlOcr
|
from module.ocr.al_ocr import AlOcr
|
||||||
|
|
||||||
if server.server == 'jp':
|
|
||||||
import pyocr
|
|
||||||
|
|
||||||
OCR_MODEL = {
|
OCR_MODEL = {
|
||||||
# Folder: ./bin/cnocr_models/azur_lane
|
# Folder: ./bin/cnocr_models/azur_lane
|
||||||
# Size: 3.25MB
|
# Size: 3.25MB
|
||||||
@@ -32,6 +29,8 @@ OCR_MODEL = {
|
|||||||
# Charset: Number, English character, Chinese character, symbols, <space>
|
# Charset: Number, English character, Chinese character, symbols, <space>
|
||||||
# _num_classes: 6426
|
# _num_classes: 6426
|
||||||
'cnocr': AlOcr(model_name='densenet-lite-gru', model_epoch=39, root='./bin/cnocr_models/cnocr', name='cnocr'),
|
'cnocr': AlOcr(model_name='densenet-lite-gru', model_epoch=39, root='./bin/cnocr_models/cnocr', name='cnocr'),
|
||||||
|
|
||||||
|
'jp': AlOcr(model_name='densenet-lite-gru', model_epoch=125, root='./bin/cnocr_models/jp', name='jp'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,72 +101,6 @@ class Ocr:
|
|||||||
return result_list
|
return result_list
|
||||||
|
|
||||||
|
|
||||||
class OcrJapanese:
|
|
||||||
def __init__(self, buttons, letter=(255, 255, 255), threshold=128, name=None):
|
|
||||||
"""
|
|
||||||
Args:
|
|
||||||
buttons (Button, tuple, list[Button], list[tuple]): OCR area.
|
|
||||||
letter (tuple(int)): Letter RGB.
|
|
||||||
threshold (int):
|
|
||||||
name (str):
|
|
||||||
"""
|
|
||||||
self.name = str(buttons) if isinstance(buttons, Button) else name
|
|
||||||
self.buttons = buttons if isinstance(buttons, list) else [buttons]
|
|
||||||
self.buttons = [button.area if isinstance(
|
|
||||||
button, Button) else button for button in self.buttons]
|
|
||||||
self.letter = letter
|
|
||||||
self.threshold = threshold
|
|
||||||
self.ocr_tool = self.find_tesseract_tool()
|
|
||||||
|
|
||||||
def find_tesseract_tool(self):
|
|
||||||
"""
|
|
||||||
Returns:
|
|
||||||
pyocr tesseract wrapper module
|
|
||||||
"""
|
|
||||||
ocr_tool = pyocr.get_available_tools()
|
|
||||||
if len(ocr_tool) == 0:
|
|
||||||
raise ScriptError(
|
|
||||||
'No ocr-tool found, please install tesseract by yourself and make sure to set correct env vars.')
|
|
||||||
ocr_tool = ocr_tool[0]
|
|
||||||
ocr_langs = ocr_tool.get_available_languages()
|
|
||||||
if 'jpn' not in ocr_langs:
|
|
||||||
raise ScriptError(
|
|
||||||
'No jpn found in tesseract langs, please install japanese data files.')
|
|
||||||
return ocr_tool
|
|
||||||
|
|
||||||
def pre_process(self, image):
|
|
||||||
"""
|
|
||||||
Args:
|
|
||||||
image (np.ndarray): Shape (height, width, channel)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
PIL.Image
|
|
||||||
"""
|
|
||||||
image = extract_letters(
|
|
||||||
image, letter=self.letter, threshold=self.threshold)
|
|
||||||
|
|
||||||
return Image.fromarray(image)
|
|
||||||
|
|
||||||
def ocr(self, image):
|
|
||||||
start_time = time.time()
|
|
||||||
|
|
||||||
image_list = [self.pre_process(np.array(image.crop(area)))
|
|
||||||
for area in self.buttons]
|
|
||||||
|
|
||||||
# This will show the images feed to OCR model
|
|
||||||
# self.cnocr.debug(image_list)
|
|
||||||
|
|
||||||
result_list = [self.ocr_tool.image_to_string(
|
|
||||||
img, lang='jpn') for img in image_list]
|
|
||||||
|
|
||||||
if len(self.buttons) == 1:
|
|
||||||
result_list = result_list[0]
|
|
||||||
logger.attr(name='%s %ss' % (self.name, float2str(time.time() - start_time)),
|
|
||||||
text=str(result_list))
|
|
||||||
|
|
||||||
return result_list
|
|
||||||
|
|
||||||
|
|
||||||
class Digit(Ocr):
|
class Digit(Ocr):
|
||||||
def __init__(self, buttons, lang='azur_lane', letter=(255, 255, 255), threshold=128, alphabet='0123456789',
|
def __init__(self, buttons, lang='azur_lane', letter=(255, 255, 255), threshold=128, alphabet='0123456789',
|
||||||
name=None):
|
name=None):
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from module.base.utils import color_similar_1d, random_rectangle_point
|
|||||||
from module.exception import GameStuckError
|
from module.exception import GameStuckError
|
||||||
from module.handler.info_handler import InfoHandler
|
from module.handler.info_handler import InfoHandler
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Ocr, OcrJapanese
|
from module.ocr.ocr import Ocr
|
||||||
from module.reward.assets import *
|
from module.reward.assets import *
|
||||||
from module.ui.page import page_reward, page_commission, CAMPAIGN_CHECK
|
from module.ui.page import page_reward, page_commission, CAMPAIGN_CHECK
|
||||||
from module.ui.switch import Switch
|
from module.ui.switch import Switch
|
||||||
@@ -53,19 +53,19 @@ dictionary_en = {
|
|||||||
}
|
}
|
||||||
dictionary_jp = {
|
dictionary_jp = {
|
||||||
'major_comm': ['初級自主訓練', '中級自主訓練', '上級自主訓練', '初級対抗演習', '中級対抗演習', '上級対抗演習', '初級科学研究', '中級科学研究', '上級科学研究', '初級資材整理', '中級資材整理', '上級資材整理', '初級戦術課程', '中級戦術課程', '上級戦術課程', '初級貨物輸送', '中級貨物輸送', '上級貨物輸送'],
|
'major_comm': ['初級自主訓練', '中級自主訓練', '上級自主訓練', '初級対抗演習', '中級対抗演習', '上級対抗演習', '初級科学研究', '中級科学研究', '上級科学研究', '初級資材整理', '中級資材整理', '上級資材整理', '初級戦術課程', '中級戦術課程', '上級戦術課程', '初級貨物輸送', '中級貨物輸送', '上級貨物輸送'],
|
||||||
'daily_comm': ['日常資源開発Ⅰ', '日常資源開発Ⅱ', '日常資源開発Ⅲ', '日常資源開発Ⅳ', '日常資源開発Ⅴ', '日常資源開発Ⅵ', '覚醒実証研究Ⅰ', '覚醒実証研究Ⅱ'],
|
'daily_comm': ['日常資源開発', '覚醒実証研究'],
|
||||||
'extra_drill': ['短距離練習航海', '中距離練習航海', '外洋練習航海', '近海防衛巡回', '前線基地防衛巡回', '海域浮標保守作業'],
|
'extra_drill': ['短距離練習航海', '中距離練習航海', '外洋練習航海', '近海防衛巡回', '前線基地防衛巡回', '海域浮標保守作業'],
|
||||||
'extra_part': ['初級木材輸送護衛', '中級木材輸送護衛', '上級木材輸送護衛', '初級鉄鋼輸送護衛', '中級鉄鋼輸送護衛', '上級鉄鋼輸送護衛'],
|
'extra_part': ['初級木材輸送護衛', '中級木材輸送護衛', '上級木材輸送護衛', '初級鉄鋼輸送護衛', '中級鉄鋼輸送護衛', '上級鉄鋼輸送護衛'],
|
||||||
'extra_cube': ['船団護衛演習', '艦隊輸送演習', '艦隊実弾演習', '装備慣熟演習', '艦隊慣熟演習', '艦隊運動演習'],
|
'extra_cube': ['船団護衛演習', '艦隊輸送演習', '艦隊実弾演習', '装備慣熟演習', '艦隊慣熟演習', '艦隊運動演習'],
|
||||||
'extra_oil': ['小型油田開発Ⅰ', '小型油田開発Ⅱ', '小型油田開発Ⅲ', '中型油田開発Ⅰ', '中型油田開発Ⅱ', '中型油田開発Ⅲ', '大型油田開発Ⅰ', '大型油田開発Ⅱ', '大型油田開発Ⅲ'],
|
'extra_oil': ['小型油田開発', '中型油田開発', '大型油田開発'],
|
||||||
'extra_book': ['小型船団護衛', '中型船団護衛', '大型船団護衛'],
|
'extra_book': ['小型船団護衛', '中型船団護衛', '大型船団護衛'],
|
||||||
'urgent_drill': ['敵偵察部隊迎撃', '敵主力艦隊撃破', '敵精鋭部隊撃破', '輸送部隊護衛Ⅰ', '輸送部隊護衛Ⅱ', '輸送部隊護衛Ⅲ'],
|
'urgent_drill': ['敵偵察部隊迎撃', '敵主力艦隊撃破', '敵精鋭部隊撃破', '輸送部隊護衛'],
|
||||||
'urgent_part': ['近海掃海任務', '近海航行展示', '離島火力支援', '離島兵員輸送', '外敵生態調査', '兵站航路確保'],
|
'urgent_part': ['近海掃海任務', '近海航行展示', '離島火力支援', '離島兵員輸送', '外敵生態調査', '兵站航路確保'],
|
||||||
'urgent_book': ['離島物資輸送', '近海パトロール', '離島漸減支援', '外的動静哨戒', '前線部隊支援', '外敵中枢偵察'],
|
'urgent_book': ['離島物資輸送', '近海パトロール', '離島漸減支援', '外敵動静哨戒', '前線部隊支援', '外敵中枢偵察'],
|
||||||
'urgent_box': ['BIW装備輸送', 'NYB装備輸送', 'BIW物資交換', 'NYB物資交換', 'BIW装備試験', 'NYB装備試験'],
|
'urgent_box': ['装備輸送', '物資交換', '装備試験'],
|
||||||
'urgent_cube': ['船団救出Ⅰ', '船団救出Ⅱ', '船団救出Ⅲ', '敵襲Ⅰ', '敵襲Ⅱ', '敵襲Ⅲ'],
|
'urgent_cube': ['船団救出', '敵襲'],
|
||||||
'urgent_gem': ['BIW要人護衛', 'NYB要人護衛', 'BIW休暇護衛', 'NYB休暇護衛'],
|
'urgent_gem': ['要人護衛', '休暇護衛'],
|
||||||
'urgent_ship': ['小型観覧式', '連合艦隊観覧式', '多国連合観覧式']
|
'urgent_ship': ['小型観艦式', '連合艦隊観艦式', '多国連合観艦式']
|
||||||
}
|
}
|
||||||
COMMISSION_SWITCH = Switch('Commission_switch', is_selector=True)
|
COMMISSION_SWITCH = Switch('Commission_switch', is_selector=True)
|
||||||
COMMISSION_SWITCH.add_status('daily', COMMISSION_DAILY)
|
COMMISSION_SWITCH.add_status('daily', COMMISSION_DAILY)
|
||||||
@@ -132,9 +132,9 @@ class Commission:
|
|||||||
# Name
|
# Name
|
||||||
area = area_offset((176, 23, 420, 53), self.area[0:2])
|
area = area_offset((176, 23, 420, 53), self.area[0:2])
|
||||||
button = Button(area=area, color=(), button=area, name='COMMISSION')
|
button = Button(area=area, color=(), button=area, name='COMMISSION')
|
||||||
ocr_jpn = OcrJapanese(button)
|
ocr = Ocr(button, lang='jp')
|
||||||
self.button = button
|
self.button = button
|
||||||
self.name = ocr_jpn.ocr(self.image)
|
self.name = ocr.ocr(self.image)
|
||||||
self.genre = self.commission_name_parse(self.name)
|
self.genre = self.commission_name_parse(self.name)
|
||||||
|
|
||||||
# Duration time
|
# Duration time
|
||||||
@@ -281,7 +281,7 @@ class Commission:
|
|||||||
"""
|
"""
|
||||||
min_key = ''
|
min_key = ''
|
||||||
min_distance = 100
|
min_distance = 100
|
||||||
string = re.sub(' ', '', string)
|
string = re.sub(r'[\x00-\x7F]', '', string)
|
||||||
for key, value in dictionary_jp.items():
|
for key, value in dictionary_jp.items():
|
||||||
for keyword in value:
|
for keyword in value:
|
||||||
distance = Levenshtein.distance(keyword, string)
|
distance = Levenshtein.distance(keyword, string)
|
||||||
|
|||||||
@@ -12,5 +12,4 @@ mxnet==1.6.0
|
|||||||
cnocr==1.2.2
|
cnocr==1.2.2
|
||||||
gooey
|
gooey
|
||||||
colored
|
colored
|
||||||
python-Levenshtein
|
python-Levenshtein
|
||||||
pyocr
|
|
||||||
Reference in New Issue
Block a user