@@ -150,30 +150,37 @@ class LocalAnalyzer:
|
||||
if person_result['confirmed_change']:
|
||||
metrics['person_count_change'] = person_count_change
|
||||
|
||||
# 记录人员事件
|
||||
# 记录人员事件(带序号)
|
||||
for person in person_result['persons']:
|
||||
person_index = person.get('person_index', 1)
|
||||
detection_source = person.get('source', 'unknown')
|
||||
|
||||
if person['is_new']:
|
||||
events.append({
|
||||
'event_type': '人物活动',
|
||||
'description': f'新人出现: {person["name"]},当前共 {current_count} 人',
|
||||
'description': f'#{person_index} 新人: {person["name"]} [{detection_source}],当前共 {current_count} 人',
|
||||
'confidence': '高',
|
||||
'source': 'local'
|
||||
'source': 'local',
|
||||
'person_index': person_index
|
||||
})
|
||||
self.human_count += 1
|
||||
self.person_change_count += 1
|
||||
else:
|
||||
events.append({
|
||||
'event_type': '人物活动',
|
||||
'description': f'已知人员: {person["name"]} [{person.get("source", "detected")}]',
|
||||
'description': f'#{person_index} 已知人员: {person["name"]} [{detection_source}]',
|
||||
'confidence': '高',
|
||||
'source': 'local'
|
||||
'source': 'local',
|
||||
'person_index': person_index
|
||||
})
|
||||
|
||||
# 检测人员进出
|
||||
# 检测人员进出(带序号)
|
||||
if person_count_change > 0:
|
||||
# 列出新进入的人员序号
|
||||
new_indices = [p.get('person_index', i+1) for i, p in enumerate(person_result['persons'][-person_count_change:])]
|
||||
events.append({
|
||||
'event_type': '人员进出',
|
||||
'description': f'检测到 {person_count_change} 人进入,当前共 {current_count} 人 [{person_result.get("detection_source", "")}]',
|
||||
'description': f'#{", #".join(map(str, new_indices))} 进入,当前共 {current_count} 人 [{person_result.get("detection_source", "")}]',
|
||||
'confidence': '高',
|
||||
'source': 'local'
|
||||
})
|
||||
@@ -181,7 +188,7 @@ class LocalAnalyzer:
|
||||
elif person_count_change < 0:
|
||||
events.append({
|
||||
'event_type': '人员进出',
|
||||
'description': f'检测到 {abs(person_count_change)} 人离开,当前剩 {current_count} 人',
|
||||
'description': f'{abs(person_count_change)} 人离开,当前剩 {current_count} 人',
|
||||
'confidence': '高',
|
||||
'source': 'local'
|
||||
})
|
||||
|
||||
@@ -441,6 +441,9 @@ class PersonManager:
|
||||
confirmed_change = False
|
||||
confirmed_persons = []
|
||||
|
||||
# 为每个检测到的人分配序号
|
||||
person_index = self.prev_human_count # 从当前人数开始
|
||||
|
||||
# 检查人数变化
|
||||
prev_count = len(self.prev_persons)
|
||||
|
||||
@@ -452,16 +455,20 @@ class PersonManager:
|
||||
|
||||
self.confirmation_buffer[key]['count'] += 1
|
||||
|
||||
# 临时识别人员
|
||||
# 临时识别人员并分配序号
|
||||
temp_persons = []
|
||||
for face in faces:
|
||||
for idx, face in enumerate(faces):
|
||||
bbox = face['bbox']
|
||||
encoding = self.extract_face_encoding(image, bbox)
|
||||
match_result = self.match_face(encoding)
|
||||
|
||||
# 分配人员序号
|
||||
person_index_display = idx + 1 # 序号从1开始
|
||||
|
||||
person_info = {
|
||||
'person_id': match_result['person_id'] if not match_result['is_new'] else 'unknown',
|
||||
'name': match_result['name'],
|
||||
'person_id': match_result['person_id'] if not match_result['is_new'] else f"unknown_{person_index_display}",
|
||||
'name': match_result['name'] if not match_result['is_new'] else f"Person #{person_index_display}",
|
||||
'person_index': person_index_display, # 显示序号
|
||||
'bbox': bbox,
|
||||
'is_new': match_result['is_new'],
|
||||
'confidence': face['confidence'],
|
||||
@@ -477,6 +484,8 @@ class PersonManager:
|
||||
confirmed_persons = temp_persons
|
||||
|
||||
print(f"[PersonManager] Confirmed: {prev_count} -> {current_count} persons (after {self.config['confirm_frames']} frames)")
|
||||
for p in confirmed_persons:
|
||||
print(f" - {p['name']} (#{p['person_index']}) [{p['source']}]")
|
||||
|
||||
# 清空其他缓冲区
|
||||
self.confirmation_buffer = {}
|
||||
@@ -487,16 +496,19 @@ class PersonManager:
|
||||
else:
|
||||
# 人数不变,清空变化缓冲区,维持当前状态
|
||||
if current_count > 0:
|
||||
# 识别当前人员
|
||||
# 识别当前人员并分配序号
|
||||
temp_persons = []
|
||||
for face in faces:
|
||||
for idx, face in enumerate(faces):
|
||||
bbox = face['bbox']
|
||||
encoding = self.extract_face_encoding(image, bbox)
|
||||
match_result = self.match_face(encoding)
|
||||
|
||||
person_index_display = idx + 1
|
||||
|
||||
person_info = {
|
||||
'person_id': match_result['person_id'] if not match_result['is_new'] else 'unknown',
|
||||
'name': match_result['name'],
|
||||
'person_id': match_result['person_id'] if not match_result['is_new'] else f"unknown_{person_index_display}",
|
||||
'name': match_result['name'] if not match_result['is_new'] else f"Person #{person_index_display}",
|
||||
'person_index': person_index_display,
|
||||
'bbox': bbox,
|
||||
'is_new': match_result['is_new'],
|
||||
'confidence': face['confidence'],
|
||||
|
||||
@@ -371,11 +371,30 @@ button {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.event-card.type-人员进出 .event-type::before,
|
||||
.event-card.type-人物活动 .event-type::before {
|
||||
content: "#";
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.event-card.source-local .event-type {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.event-card.source-local .event-type::after {
|
||||
content: "";
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.event-desc {
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.event-desc strong {
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.event-confidence {
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
|
||||
Reference in New Issue
Block a user