|
@@ -1,6 +1,7 @@
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
import json
|
|
|
from base64 import b64decode
|
|
|
+import base64
|
|
|
|
|
|
import cv2
|
|
|
import numpy as np
|
|
@@ -111,17 +112,20 @@ def predict_cls(image, conf=0.8):
|
|
|
score = res[0]['scores'][0]
|
|
|
label_name = res[0]['label_names'][0]
|
|
|
print(f"score: {score}, label_name: {label_name}")
|
|
|
+ # print(conf)
|
|
|
if score > conf:
|
|
|
return int(label_name)
|
|
|
return -1
|
|
|
|
|
|
|
|
|
def rotate_to_zero(image, current_degree):
|
|
|
+ # cv2.imwrite('1.jpg', image)
|
|
|
current_degree = current_degree // 90
|
|
|
if current_degree == 0:
|
|
|
return image
|
|
|
to_rotate = (4 - current_degree) - 1
|
|
|
image = cv2.rotate(image, to_rotate)
|
|
|
+ # cv2.imwrite('2.jpg', image)
|
|
|
return image
|
|
|
|
|
|
|
|
@@ -143,11 +147,13 @@ def get_zero_degree_image(img):
|
|
|
|
|
|
def table_res(im, ROTATE=-1):
|
|
|
im = im.copy()
|
|
|
+ cv2.imwrite('before-rotate.jpg', im)
|
|
|
# 获取正向图片
|
|
|
img = get_zero_degree_image(im)
|
|
|
- # cv2.imwrite('1.jpg', img)
|
|
|
+ cv2.imwrite('after-rotate.jpg', img)
|
|
|
try:
|
|
|
table_engine_lock.acquire()
|
|
|
+ # cv2.imwrite('3.jpg', img)
|
|
|
res = table_engine(img)
|
|
|
finally:
|
|
|
table_engine_lock.release()
|