Spaces:
Sleeping
Sleeping
Commit ·
810fd71
1
Parent(s): 99522f4
Update api.py
Browse files
api.py
CHANGED
|
@@ -24,6 +24,8 @@ def get_time():
|
|
| 24 |
try: # If your backend has any problem and you are not getting any error in logs, then remove this try except to see error.
|
| 25 |
file = request.files['file']
|
| 26 |
file.save(secure_filename(file.filename))
|
|
|
|
|
|
|
| 27 |
except:
|
| 28 |
return["Sorry something went wrong. Perhaps you did not select your image. Please try again."]
|
| 29 |
rois = request.form['rois'].split(',')
|
|
@@ -31,8 +33,7 @@ def get_time():
|
|
| 31 |
|
| 32 |
print(rois, "\n", div)
|
| 33 |
|
| 34 |
-
|
| 35 |
-
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 36 |
# specify languages and other configs
|
| 37 |
reader = easyocr.Reader(['en'], gpu=False)
|
| 38 |
|
|
@@ -50,8 +51,11 @@ def get_time():
|
|
| 50 |
for i in range(int(len(rois) / 4)):
|
| 51 |
j = i * 4
|
| 52 |
global X1, X2, Y1, Y2
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
Offset_y1 = ((IacH * y1 / 100) * 0.02) / 100
|
| 56 |
Offset_y2 = ((IacH * y2 / 100) * 0.05) / 100
|
| 57 |
print(Offset_y1)
|
|
|
|
| 24 |
try: # If your backend has any problem and you are not getting any error in logs, then remove this try except to see error.
|
| 25 |
file = request.files['file']
|
| 26 |
file.save(secure_filename(file.filename))
|
| 27 |
+
img = cv2.imread(secure_filename(file.filename))
|
| 28 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 29 |
except:
|
| 30 |
return["Sorry something went wrong. Perhaps you did not select your image. Please try again."]
|
| 31 |
rois = request.form['rois'].split(',')
|
|
|
|
| 33 |
|
| 34 |
print(rois, "\n", div)
|
| 35 |
|
| 36 |
+
|
|
|
|
| 37 |
# specify languages and other configs
|
| 38 |
reader = easyocr.Reader(['en'], gpu=False)
|
| 39 |
|
|
|
|
| 51 |
for i in range(int(len(rois) / 4)):
|
| 52 |
j = i * 4
|
| 53 |
global X1, X2, Y1, Y2
|
| 54 |
+
try:
|
| 55 |
+
x1, y1, x2, y2 = int(rois[j]), int(rois[j + 1]), int(rois[j + 2]), int(rois[j + 3])
|
| 56 |
+
X1, Y1, X2, Y2 = int(Rw * x1), Rh * y1, int(Rw * x2), Rh * y2
|
| 57 |
+
except:
|
| 58 |
+
return ["Sorry something went wrong. Perhaps you did not select your image. Please try again."]
|
| 59 |
Offset_y1 = ((IacH * y1 / 100) * 0.02) / 100
|
| 60 |
Offset_y2 = ((IacH * y2 / 100) * 0.05) / 100
|
| 61 |
print(Offset_y1)
|