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('/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:
|
||||
|
||||
Reference in New Issue
Block a user