-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_app_model.py
35 lines (31 loc) · 926 Bytes
/
test_app_model.py
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
35
import os
from ocr import ocr
import time
import shutil
import numpy as np
from PIL import Image, ImageOps
from glob import glob
import cv2
def single_pic_proc(image_file):
image = Image.open(image_file).convert('RGB')
image = ImageOps.exif_transpose(image)
image = np.array(image)
result, image_framed = ocr(image)
return result, image_framed
def dis(image):
cv2.imshow('image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
if __name__ == '__main__':
import sys
if len(sys.argv) >= 2:
filename = sys.argv[1]
if filename.endswith('jpg') or filename.endswith('png'):
result, image_framed = single_pic_proc(filename)
#print(result)
allresults = ""
for key in result:
#print(result[key][1])
allresults += result[key][1] + '\n'
print(allresults)
#dis(image_framed)