diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 9de24676612d8b63f98a334bbad96f250f8fe8c9..4d9c52740a5ca5bcdd891bb55ff769f23e7a2499 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -24,6 +24,7 @@ import sys from functools import partial from collections import defaultdict import json +import cv2 __dir__ = os.path.dirname(os.path.abspath(__file__)) @@ -1242,10 +1243,13 @@ class MainWindow(QMainWindow, WindowMixin): # if unicodeFilePath in self.mImgList: if unicodeFilePath and os.path.exists(unicodeFilePath): - self.imageData = read(unicodeFilePath, None) self.canvas.verified = False - image = QImage.fromData(self.imageData) + cvimg = cv2.imdecode(np.fromfile(unicodeFilePath, dtype=np.uint8), 1) + height, width, depth = cvimg.shape + cvimg = cv2.cvtColor(cvimg, cv2.COLOR_BGR2RGB) + image = QImage(cvimg.data, width, height, width * depth, QImage.Format_RGB888) + if image.isNull(): self.errorMessage(u'Error opening file', u"

Make sure %s is a valid image file." % unicodeFilePath) diff --git a/PPOCRLabel/libs/autoDialog.py b/PPOCRLabel/libs/autoDialog.py index 09fbeb56b31b82bff8152f5e0b9a779f06b18985..3374e92cc587baa7e8bab5c7d8e8dc34eb6366b6 100644 --- a/PPOCRLabel/libs/autoDialog.py +++ b/PPOCRLabel/libs/autoDialog.py @@ -7,6 +7,8 @@ except ImportError: from PyQt4.QtCore import * import json +import cv2 +import numpy as np from libs.utils import newIcon @@ -34,11 +36,16 @@ class Worker(QThread): if self.handle == 0: self.listValue.emit(Imgpath) if self.model == 'paddle': - self.result_dic = self.ocr.ocr(Imgpath, cls=True, det=True) + h, w, _ = cv2.imdecode(np.fromfile(Imgpath, dtype=np.uint8), 1).shape + if h > 32 and w > 32: + self.result_dic = self.ocr.ocr(Imgpath, cls=True, det=True) + else: + print('The size of', Imgpath, 'is too small to be recognised') + self.result_dic = None # 结果保存 if self.result_dic is None or len(self.result_dic) == 0: - print('Can not recognise file is : ', Imgpath) + print('Can not recognise file', Imgpath) pass else: strs = '' diff --git a/doc/joinus.PNG b/doc/joinus.PNG index 317877a2d0091c98d98d8ea88e80091533ad046d..ee505a0c78b8625b0faadc9a6bc28980440158e5 100644 Binary files a/doc/joinus.PNG and b/doc/joinus.PNG differ