@@ -1248,9 +1248,10 @@ def createPolygon(self):
1248
1248
1249
1249
def rotateImg (self , filename , k , _value ):
1250
1250
self .actions .rotateRight .setEnabled (_value )
1251
- pix = cv2 .imread ( filename )
1251
+ pix = cv2 .imdecode ( np . fromfile ( filename , dtype = np . uint8 ), cv2 . IMREAD_COLOR )
1252
1252
pix = np .rot90 (pix , k )
1253
- cv2 .imwrite (filename , pix )
1253
+ ext = os .path .splitext (filename )[1 ]
1254
+ cv2 .imencode (ext , pix )[1 ].tofile (filename )
1254
1255
self .canvas .update ()
1255
1256
self .loadFile (filename )
1256
1257
@@ -2387,7 +2388,9 @@ def _saveFile(self, annotationFilePath, mode="Manual"):
2387
2388
2388
2389
if mode == "Manual" :
2389
2390
self .result_dic_locked = []
2390
- img = cv2 .imread (self .filePath )
2391
+ img = cv2 .imdecode (
2392
+ np .fromfile (self .filePath , dtype = np .uint8 ), cv2 .IMREAD_COLOR
2393
+ )
2391
2394
width , height = self .image .width (), self .image .height ()
2392
2395
for shape in self .canvas .lockedShapes :
2393
2396
box = [[int (p [0 ] * width ), int (p [1 ] * height )] for p in shape ["ratio" ]]
@@ -2823,7 +2826,7 @@ def TableRecognition(self):
2823
2826
import time
2824
2827
2825
2828
start = time .time ()
2826
- img = cv2 .imread ( self .filePath )
2829
+ img = cv2 .imdecode ( np . fromfile ( self .filePath , dtype = np . uint8 ), cv2 . IMREAD_COLOR )
2827
2830
res = self .table_ocr (img , return_ocr_result_in_table = True )
2828
2831
2829
2832
TableRec_excel_dir = self .lastOpenDir + "/tableRec_excel_output/"
@@ -2954,7 +2957,7 @@ def cellreRecognition(self):
2954
2957
"""
2955
2958
re-recognise text in a cell
2956
2959
"""
2957
- img = cv2 .imread ( self .filePath )
2960
+ img = cv2 .imdecode ( np . fromfile ( self .filePath , dtype = np . uint8 ), cv2 . IMREAD_COLOR )
2958
2961
for shape in self .canvas .selectedShapes :
2959
2962
box = [[int (p .x ()), int (p .y ())] for p in shape .points ]
2960
2963
0 commit comments