Skip to content

Commit ef14205

Browse files
author
[xct24]
committed
v0.1.4-beta4
1. 使用numpy修正了之前部分人会因为中文路径出现读取refImage失败的问题 2. 优化了一下错误处理器
1 parent fdc7c1b commit ef14205

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

exceptHookHandler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ def __HandleException(self, excType, excValue, tb):
5555
sys.__excepthook__(excType, excValue, tb)
5656

5757
err_msg = ''.join(traceback.format_exception(excType, excValue, tb))
58-
err_msg += '\n最后一次请求JSON: %s' % self.__mainGUI.lastRequestJson
59-
err_msg += '\n最后一次返回JSON: %s' % self.__mainGUI.lastResponseJson
58+
err_msg += 'excType: %s' % excType
59+
err_msg += 'excValue: %s' % excValue
60+
err_msg += 'tb: %s' % tb
6061
err_msg += '\nPCRJJCAnalyzer遇到了意料之外的错误。请在反馈时附上本对话框截图。'
6162
# Here collecting traceback and some log files to be sent for debugging.
6263
# But also possible to handle the error and continue working.

main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#! /usr/bin/env python
22
#-*- coding: utf-8 -*-
33

4+
import numpy as np
45
import json
56
import util
67
import copy
@@ -130,8 +131,9 @@ def run(self):
130131
base_path = sys._MEIPASS
131132
else:
132133
base_path = os.path.abspath(".")
134+
# 尝试修正可能出现的中文路径编码问题
133135
refImagePath = os.path.join(base_path, 'resource/refImage.png')
134-
refImage = cv2.imread(refImagePath) # 读取参考图
136+
refImage = cv2.imdecode(np.fromfile(refImagePath,dtype=np.uint8),cv2.IMREAD_COLOR) # 读取参考图
135137
charIndexCandidateList = [[],[],[],[],[],[]]
136138
charCandidateList = [
137139
{'name': '未知角色', 'id': 1000},
@@ -425,17 +427,14 @@ def renderSolution(self, solution, mainGUI, buttonGroup):
425427
global_logger.exception("renderSolution()渲染错误")
426428
global_logger.exception("渲染用solution: %s" % solution)
427429
global_logger.exception("Exception %s" % e)
428-
429-
430430

431-
432431

433432
class GUIMainWin(QMainWindow, Ui_PCRJJCAnalyzerGUI):
434433
def __init__(self, parent=None):
435434
super(GUIMainWin, self).__init__(parent)
436435
self.setupUi(self)
437436
self.appExceptionHandler = ExceptHookHandler(self, logFile=os.path.join(os.path.expanduser('~'), "PCRJJCAnalyzer", "log.txt"))
438-
self.setWindowTitle('PCRJJCAnalyzer-v0.1.4-beta3')
437+
self.setWindowTitle('PCRJJCAnalyzer-v0.1.4-beta4')
439438
self.exclusionList = [[], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
440439
self.excludingSolutionIDList = ['','','']
441440
self.exclusionCheckBoxButtonGroup = QButtonGroup()
@@ -989,8 +988,9 @@ def parseChars(self):
989988
base_path = sys._MEIPASS
990989
else:
991990
base_path = os.path.abspath(".")
991+
# 尝试修正可能出现的中文路径编码问题
992992
refImagePath = os.path.join(base_path, 'resource/refImage.png')
993-
refImage = cv2.imread(refImagePath) # 读取参考图
993+
refImage = cv2.imdecode(np.fromfile(refImagePath,dtype=np.uint8),cv2.IMREAD_COLOR) # 读取参考图
994994
for i in range(len(self.charImageList)):
995995
charNum = i+1
996996
charIndex = (util.cv_getIndex(util.cv_getMidPoint(self.charImageList[i], refImage, eval("cv2.%s" % config_dict['algorithm'] )), refImageParams)) # 计算出目标角色在参考图中的坐标位置(行与列)

0 commit comments

Comments
 (0)