识别结果保存到对应目录下后不显示完整路径
This commit is contained in:
29
core/all.py
29
core/all.py
@ -38,31 +38,34 @@ def detect(frame):
|
||||
yolo_flag, yolo_result = yoloDetect(frame)
|
||||
print(f"YOLO检测结果:{yolo_result}")
|
||||
if yolo_flag:
|
||||
# 直接调用路径生成函数,无需传入原始图片名
|
||||
save_path = get_image_save_path(model_type="yolo")
|
||||
if save_path:
|
||||
cv2.imwrite(save_path, frame)
|
||||
print(f"✅ YOLO违规图片已保存:{save_path}")
|
||||
# 元组解构:获取「完整保存路径」和「显示用短路径」
|
||||
full_save_path, display_path = get_image_save_path(model_type="yolo")
|
||||
if full_save_path: # 只判断完整路径是否有效(用于保存)
|
||||
cv2.imwrite(full_save_path, frame)
|
||||
# 打印时使用「显示用短路径」,符合需求格式
|
||||
print(f"✅ YOLO违规图片已保存:{display_path}")
|
||||
return (True, yolo_result, "yolo")
|
||||
|
||||
# 2. 人脸检测(优先级2)
|
||||
face_flag, face_result = faceDetect(frame)
|
||||
print(f"人脸检测结果:{face_result}")
|
||||
if face_flag:
|
||||
save_path = get_image_save_path(model_type="face")
|
||||
if save_path:
|
||||
cv2.imwrite(save_path, frame)
|
||||
print(f"✅ 人脸违规图片已保存:{save_path}")
|
||||
# 同样解构元组,分离保存路径和显示路径
|
||||
full_save_path, display_path = get_image_save_path(model_type="face")
|
||||
if full_save_path:
|
||||
cv2.imwrite(full_save_path, frame)
|
||||
print(f"✅ 人脸违规图片已保存:{display_path}")
|
||||
return (True, face_result, "face")
|
||||
|
||||
# 3. OCR检测(优先级3)
|
||||
ocr_flag, ocr_result = ocrDetect(frame)
|
||||
print(f"OCR检测结果:{ocr_result}")
|
||||
if ocr_flag:
|
||||
save_path = get_image_save_path(model_type="ocr")
|
||||
if save_path:
|
||||
cv2.imwrite(save_path, frame)
|
||||
print(f"✅ OCR违规图片已保存:{save_path}")
|
||||
# 解构元组,保存用完整路径,打印用短路径
|
||||
full_save_path, display_path = get_image_save_path(model_type="ocr")
|
||||
if full_save_path:
|
||||
cv2.imwrite(full_save_path, frame)
|
||||
print(f"✅ OCR违规图片已保存:{display_path}")
|
||||
return (True, ocr_result, "ocr")
|
||||
|
||||
# 4. 无违规内容(不保存图片)
|
||||
|
Reference in New Issue
Block a user