尝试修复回溯帧bug
This commit is contained in:
@@ -142,11 +142,11 @@ class KadianDetector:
|
|||||||
self.nobody_frames = 0 # 累计无人在场帧数
|
self.nobody_frames = 0 # 累计无人在场帧数
|
||||||
self.only_one_frames = 0 # 累计单人在场帧数
|
self.only_one_frames = 0 # 累计单人在场帧数
|
||||||
|
|
||||||
self.max_car_frames = int((8.0 + self.TIME_TOLERANCE_CAR) * self.fps) # 50帧
|
self.max_car_frames = int((15.0 + self.TIME_TOLERANCE_CAR) * self.fps) #
|
||||||
self.frame_buffer_ignore_untrunk = deque(maxlen=self.max_car_frames)
|
self.frame_buffer_ignore_untrunk = deque(maxlen=self.max_car_frames)
|
||||||
|
|
||||||
self.untrunk_rollback_time = 5.0 # 未检查后备箱需要回溯的时间
|
self.untrunk_rollback_time = 12.0 # 未检查后备箱需要回溯的时间
|
||||||
self.ignored_rollback_time = 3.0 # 漏检需要回溯的时间
|
self.ignored_rollback_time = 12.0 # 漏检需要回溯的时间
|
||||||
|
|
||||||
|
|
||||||
def _get_roi_points(self, frame_width: int, frame_height: int):
|
def _get_roi_points(self, frame_width: int, frame_height: int):
|
||||||
@@ -219,7 +219,7 @@ class KadianDetector:
|
|||||||
target_frame = None
|
target_frame = None
|
||||||
min_time_diff = float('inf')
|
min_time_diff = float('inf')
|
||||||
for buffered in self.frame_buffer_ignore_untrunk:
|
for buffered in self.frame_buffer_ignore_untrunk:
|
||||||
time_diff = abs(buffered['frame_idx'] - target_time_sec)
|
time_diff = abs(buffered['timestamp'] - target_time_sec)
|
||||||
if time_diff < min_time_diff:
|
if time_diff < min_time_diff:
|
||||||
min_time_diff = time_diff
|
min_time_diff = time_diff
|
||||||
target_frame = buffered['frame']
|
target_frame = buffered['frame']
|
||||||
@@ -327,15 +327,14 @@ class KadianDetector:
|
|||||||
self.roi_car_registry[tid] = {
|
self.roi_car_registry[tid] = {
|
||||||
'first_seen': self.current_frame_idx,
|
'first_seen': self.current_frame_idx,
|
||||||
'last_seen': self.current_frame_idx,
|
'last_seen': self.current_frame_idx,
|
||||||
# 'first_seen': current_time_sec,
|
'last_seen_time': current_time_sec,
|
||||||
# 'last_seen': current_time_sec,
|
|
||||||
'trunk_frames': 0,
|
'trunk_frames': 0,
|
||||||
'is_checked': False,
|
'is_checked': False,
|
||||||
#'frame_buffer': deque(maxlen=self.max_car_frames), # 新增
|
#'frame_buffer': deque(maxlen=self.max_car_frames), # 新增
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self.roi_car_registry[tid]['last_seen'] = self.current_frame_idx
|
self.roi_car_registry[tid]['last_seen'] = self.current_frame_idx
|
||||||
#self.roi_car_registry[tid]['last_seen'] = current_time_sec
|
self.roi_car_registry[tid]['last_seen_time'] = current_time_sec
|
||||||
label += " IN"
|
label += " IN"
|
||||||
elif role == "opentrunk":
|
elif role == "opentrunk":
|
||||||
color = (255, 165, 0) # 橙色
|
color = (255, 165, 0) # 橙色
|
||||||
@@ -378,8 +377,8 @@ class KadianDetector:
|
|||||||
# 'frame': frame.copy(),
|
# 'frame': frame.copy(),
|
||||||
# })
|
# })
|
||||||
self.frame_buffer_ignore_untrunk.append({
|
self.frame_buffer_ignore_untrunk.append({
|
||||||
#'frame_idx': current_time_sec,
|
|
||||||
'frame_idx': self.current_frame_idx,
|
'frame_idx': self.current_frame_idx,
|
||||||
|
'timestamp': current_time_sec,
|
||||||
'frame': frame.copy(),
|
'frame': frame.copy(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -431,7 +430,7 @@ class KadianDetector:
|
|||||||
self.fast_pass_alerts[car_id] = self.current_frame_idx + int(self.ignore_show_seconds * self.fps)
|
self.fast_pass_alerts[car_id] = self.current_frame_idx + int(self.ignore_show_seconds * self.fps)
|
||||||
#self.fast_pass_alerts[car_id] = current_time_sec + int(self.ignore_show_seconds * self.fps)
|
#self.fast_pass_alerts[car_id] = current_time_sec + int(self.ignore_show_seconds * self.fps)
|
||||||
|
|
||||||
target_time_sec = car_info['last_seen'] - self.ignored_rollback_time
|
target_time_sec = car_info['last_seen_time'] - self.ignored_rollback_time
|
||||||
ignored_trunk_frame = self.find_target_frame(target_time_sec)
|
ignored_trunk_frame = self.find_target_frame(target_time_sec)
|
||||||
|
|
||||||
|
|
||||||
@@ -442,7 +441,7 @@ class KadianDetector:
|
|||||||
self.unchecked_trunk_alerts[car_id] = self.current_frame_idx + int(self.openTrunk_show_seconds * self.fps)
|
self.unchecked_trunk_alerts[car_id] = self.current_frame_idx + int(self.openTrunk_show_seconds * self.fps)
|
||||||
#self.unchecked_trunk_alerts[car_id] = current_time_sec + int(self.openTrunk_show_seconds * self.fps)
|
#self.unchecked_trunk_alerts[car_id] = current_time_sec + int(self.openTrunk_show_seconds * self.fps)
|
||||||
|
|
||||||
target_time_sec = car_info['last_seen'] - self.untrunk_rollback_time
|
target_time_sec = car_info['last_seen_time'] - self.untrunk_rollback_time
|
||||||
unchecked_trunk_frame = self.find_target_frame(target_time_sec)
|
unchecked_trunk_frame = self.find_target_frame(target_time_sec)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user