Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持中文路径 #23

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions PPOCRLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,10 @@ def createPolygon(self):

def rotateImg(self, filename, k, _value):
self.actions.rotateRight.setEnabled(_value)
pix = cv2.imread(filename)
pix = cv2.imdecode(np.fromfile(filename, dtype=np.uint8), cv2.IMREAD_COLOR)
pix = np.rot90(pix, k)
cv2.imwrite(filename, pix)
ext = os.path.splitext(filename)[1]
cv2.imencode(ext, pix)[1].tofile(filename)
self.canvas.update()
self.loadFile(filename)

Expand Down Expand Up @@ -2387,7 +2388,9 @@ def _saveFile(self, annotationFilePath, mode="Manual"):

if mode == "Manual":
self.result_dic_locked = []
img = cv2.imread(self.filePath)
img = cv2.imdecode(
np.fromfile(self.filePath, dtype=np.uint8), cv2.IMREAD_COLOR
)
width, height = self.image.width(), self.image.height()
for shape in self.canvas.lockedShapes:
box = [[int(p[0] * width), int(p[1] * height)] for p in shape["ratio"]]
Expand Down Expand Up @@ -2823,7 +2826,7 @@ def TableRecognition(self):
import time

start = time.time()
img = cv2.imread(self.filePath)
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), cv2.IMREAD_COLOR)
res = self.table_ocr(img, return_ocr_result_in_table=True)

TableRec_excel_dir = self.lastOpenDir + "/tableRec_excel_output/"
Expand Down Expand Up @@ -2954,7 +2957,7 @@ def cellreRecognition(self):
"""
re-recognise text in a cell
"""
img = cv2.imread(self.filePath)
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), cv2.IMREAD_COLOR)
for shape in self.canvas.selectedShapes:
box = [[int(p.x()), int(p.y())] for p in shape.points]

Expand Down