Commit 3519390c by 周杭

增加耗时时间

1 parent 018a16a4
......@@ -166,7 +166,7 @@ def flip_image(image,angle):
return rotated_image
def handler_vin(dst, flag, angle, path):
def handler_vin(dst, flag, angle, path,start_time):
if angle > 0:
dst = flip_image(dst, angle)
......@@ -201,10 +201,15 @@ def handler_vin(dst, flag, angle, path):
if vin_str:
print(str(row))
print(vin_str)
# 记录结束时间
end_time = time.time()
elapsed_time=end_time-start_time
# 格式化时间戳,保留两位小数
formatted_timestamp = "{:.2f}".format(elapsed_time)
# 定义要执行的SQL语句
SQL01 = f"""
INSERT INTO sys_vin_check_ocr_11 (order_id,file_id,db_vin,ocr_vin,create_time)
VALUES ({row[1]},{row[0]},'{row[9]}','{vin_str}',sysdate())
INSERT INTO sys_vin_check_ocr_11 (order_id,file_id,db_vin,ocr_vin,create_time,hssj)
VALUES ({row[1]},{row[0]},'{row[9]}','{vin_str}',sysdate(),'{formatted_timestamp}')
"""
# 执行SQL语句
print(SQL01)
......@@ -214,6 +219,9 @@ def handler_vin(dst, flag, angle, path):
# 下载图片数据
for index, row in enumerate(result):
# 记录开始时间
start_time = time.time()
print(row)
filename = generate_random_filename()
network_img_path = row[4]
......@@ -257,16 +265,16 @@ for index, row in enumerate(result):
(original_image.width * scale_factor, original_image.height * scale_factor)
)
flag = True
flag = handler_vin(dst, flag, 0, path, row)
flag = handler_vin(dst, flag, 0, path, row,start_time)
if flag:
# 旋转45度宠重新识别
flag = handler_vin(dst, flag, 45, path, row)
flag = handler_vin(dst, flag, 45, path, row,start_time)
if flag:
# 旋转90度宠重新识别
flag = handler_vin(dst, flag, 45, path, row)
flag = handler_vin(dst, flag, 45, path, row,start_time)
if flag:
# 旋转180度宠重新识别
flag = handler_vin(dst, flag, 90, path, row)
flag = handler_vin(dst, flag, 90, path, row,start_time)
if flag:
# 如果识别不了 直接再放大图片
scale_factor = 5
......@@ -276,12 +284,12 @@ for index, row in enumerate(result):
original_image.height * scale_factor,
)
)
flag = handler_vin(dst, flag, 0, path, row)
flag = handler_vin(dst, flag, 0, path, row,start_time)
if flag:
# 定义要执行的SQL语句
SQL02 = f"""
INSERT INTO sys_vin_check_ocr_11 (order_id,file_id,db_vin,ocr_vin,create_time)
VALUES ({row[1]},{row[0]},'{row[9]}',null,sysdate())
INSERT INTO sys_vin_check_ocr_11 (order_id,file_id,db_vin,ocr_vin,create_time,hssj)
VALUES ({row[1]},{row[0]},'{row[9]}',null,sysdate(),null)
"""
# 执行SQL语句
print(SQL02)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!