update for tess json
This commit is contained in:
@ -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('/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)
|
#img = cv2.imread('/Users/mohamednouffer/workspace/akira_san/sumasen_ocr/sumasen_easyocr/uploaded' + up_file.name)
|
||||||
custom_config = r'--oem 3 --psm 6'
|
custom_config = r'--oem 3 --psm 6'
|
||||||
res = pytesseract.image_to_data(img, lang='jpn', config=custom_config, output_type=Output.DICT)
|
d = pytesseract.image_to_data(img, lang='jpn', config=custom_config, output_type=Output.DICT)
|
||||||
app_json = json.dumps(res)
|
|
||||||
|
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)
|
return Response(app_json, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
{% comment %} http://aiworks.intranet.sumasen.net {% endcomment %}
|
{% comment %} http://aiworks.intranet.sumasen.net:8600/api/v1/upload {% endcomment %}
|
||||||
<body>
|
<body>
|
||||||
<h2>Sumase OCR file upload test</h2>
|
<h2>Sumase OCR file upload test</h2>
|
||||||
<form action="http://aiworks.intranet.sumasen.net:8600/api/v1/upload/" method="post" enctype="multipart/form-data">
|
<form action="http://aiworks.intranet.sumasen.net:8600/api/v1/upload/" method="post" enctype="multipart/form-data">
|
||||||
|
|||||||
Reference in New Issue
Block a user