Skip to content

Commit

Permalink
支持中文路径 (#23)
Browse files Browse the repository at this point in the history
* fixed: support Chinese path

* fixed: support Chinese path

---------

Co-authored-by: slz <[email protected]>
  • Loading branch information
sunlingzhang and slz authored Jul 4, 2024
1 parent aa42016 commit 94cc9de
Showing 1 changed file with 8 additions and 5 deletions.
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

0 comments on commit 94cc9de

Please sign in to comment.