Datasets:

ArXiv:
File size: 707 Bytes
6786d69
 
 
 
a5dc932
 
 
 
 
6786d69
a5dc932
6786d69
 
a5dc932
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6786d69
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

# C:\Users\echod\.cache\openocr\openocr_det_model.onnx
# C:\Users\echod\.cache\openocr\openocr_rec_model.onnx

# see huggingface\imradv3\main.py

import cv2
import numpy as np
import json
from openocr import OpenOCR

onnx_engine = OpenOCR(backend='onnx', device='cpu')

def jsonparse(s):
    return json.loads(s, strict=False )

def jsonstring(d):
    return json.dumps(d, ensure_ascii=False)

if __name__ == '__main__':

    img_path = 'data/t2.jpg'
    result, elapse = onnx_engine(img_path)
    s = result[0].split('\t')[1].strip()
    jsn = jsonparse(s)
    
    with open('result.json', 'w', encoding='utf-8') as f:
        f.write( jsonstring(jsn) )
    
    pass