更新了文件路径

This commit is contained in:
2025-01-12 03:48:43 +00:00
parent a93c149aca
commit 710f55345f
3 changed files with 33 additions and 3 deletions
+31 -1
View File
@@ -90,10 +90,40 @@ class ImageMonitor:
def __init__(self, images_path):
self.images_path = images_path
self.system = FaceAnalysisSystem()
self.processed_images = set()
self.processed_images = self._load_processed_images()
self.error_images = []
self.error_image_cache = set()
def _load_processed_images(self):
"""从Redis加载已处理的图片记录"""
processed = set()
try:
# 遍历所有Redis客户端
for camera_id, redis_client in self.system.redis_clients.items():
# 获取所有相关的keys
keys = redis_client.keys("face_*")
for key in keys:
data = redis_client.get(key)
if data:
hour_results = json.loads(data)
# 从每个小时数据中提取已处理的文件名
for base_name in hour_results.keys():
# 构建完整的文件路径
full_path = os.path.join(self.images_path, camera_id, base_name)
# 添加原始文件和可能的裁剪版本
base_without_ext = os.path.splitext(base_name)[0]
related_files = [f for f in os.listdir(os.path.join(self.images_path, camera_id))
if f.startswith(base_without_ext)]
for related_file in related_files:
processed.add(os.path.join(self.images_path, camera_id, related_file))
print(f"从Redis加载了 {len(processed)} 个已处理的图片记录")
return processed
except Exception as e:
print(f"加载已处理图片记录时出错: {str(e)}")
return set()
def _get_redis_key(self, image_path):
"""生成Redis键值"""
try:
+1 -1
View File
@@ -5,7 +5,7 @@ from decord import VideoReader
class VideoMonitor:
def __init__(self, recordings_path):
self.recordings_path = recordings_path
self.images_path = "/home/zydi/VLM/images"
self.images_path = "/home/zydi/WEB/images"
# 确保images目录存在
if not os.path.exists(self.images_path):
+1 -1
View File
@@ -7,7 +7,7 @@ from ultralytics import YOLO
class PoseMonitor:
def __init__(self, images_path):
self.images_path = images_path
self.crop_path = "/home/zydi/VLM/crop"
self.crop_path = "crop"
self.model = YOLO('/home/zydi/models/yolo11n-pose.pt') # 加载YOLOv8-pose模型
# 确保crop目录存在