update for tess json

This commit is contained in:
2022-01-11 19:10:06 +05:30
parent ff9e1d67ac
commit 1e8962c7d9
2 changed files with 23 additions and 3 deletions

View File

@ -45,8 +45,28 @@ class FileUploadView(APIView):
img = cv2.imread('/home/sumasen/django_easyocr_api/orc_api/sumasen_easyocr/uploaded' + up_file.name)
#img = cv2.imread('/Users/mohamednouffer/workspace/akira_san/sumasen_ocr/sumasen_easyocr/uploaded' + up_file.name)
custom_config = r'--oem 3 --psm 6'
res = pytesseract.image_to_data(img, lang='jpn', config=custom_config, output_type=Output.DICT)
app_json = json.dumps(res)
d = pytesseract.image_to_data(img, lang='jpn', config=custom_config, output_type=Output.DICT)
n_boxes = len(d['level'])
output = []
#print(d['level'])
for i in range(n_boxes):
(x, y, w, h) = (d['left'][i], d['top'][i], d['width'][i], d['height'][i])
reg = dict({
"text": d['text'][i],
"left": d['left'][i],
"top": d['top'][i],
"width": d['width'][i],
"height": d['height'][i],
"conf": d['conf'][i]
})
output.append(reg)
app_json = json.dumps(output)
return Response(app_json, status.HTTP_201_CREATED)
except Exception as e:

View File

@ -9,7 +9,7 @@
</style>
</head>
{% comment %} http://aiworks.intranet.sumasen.net {% endcomment %}
{% comment %} http://aiworks.intranet.sumasen.net:8600/api/v1/upload {% endcomment %}
<body>
<h2>Sumase OCR file upload test</h2>
<form action="http://aiworks.intranet.sumasen.net:8600/api/v1/upload/" method="post" enctype="multipart/form-data">