fix debug log

This commit is contained in:
Alberto-Audrix committed 2026-07-15 13:48:51 +07:00
1 parent 1920ff183b
commit 783b785b4f
1 file changed
+12 -30
+12 -30
View File
@@ -1357,29 +1357,23 @@ def run():
if object_det_to_track
else ""
)
crossing_str1 = ""
crossing_str2 = ""
crossing_str = ""
if object_cross_state:
seen_in_ids = sorted(
line1_ids = sorted(
tid for tid, st in object_cross_state.items() if st.get("seen_in")
)
seen_out_ids = sorted(
line2_ids = sorted(
tid for tid, st in object_cross_state.items() if st.get("seen_out")
)
counted_ids = sorted(
tid for tid, st in object_cross_state.items() if st.get("counted")
)
if seen_in_ids:
crossing_str1 = f" seen_in: {seen_in_ids}"
if seen_out_ids:
crossing_str2 = f" seen_out: {seen_out_ids}"
if counted_ids:
crossing_str2 += f" counted: {counted_ids}"
if line1_ids:
crossing_str += f" line1_crossed: {line1_ids}"
if line2_ids:
crossing_str += f" line2_crossed: {line2_ids}"
print(
f"[DEBUG F{frame_idx}] dets={len(object_boxes_xyxy)} "
f"tracks={len(object_track_map)} "
f"line_y1={line_y1} line_y2={line_y2}{scores_str}"
f"{tracks_str}{crossing_str1}{crossing_str2}"
f"{tracks_str}{crossing_str}"
)
# --- crossing detection only on DETECTED objects this frame ---
@@ -1490,25 +1484,13 @@ def run():
object_tracked[tid] = (cx, cy, mono)
continue
seq = (
"out→in"
if direction == "in" and st["seen_out"]
else (
"in→out"
if direction == "out" and st["seen_in"]
else ("in-only" if direction == "in" else "out-only")
)
)
if os.getenv("DEBUG_TRACKING", "").lower() == "true":
line_n = 1 if direction == "in" else 2
line_y = line_y1 if direction == "in" else line_y2
print(
f"[DEBUG F{frame_idx}] CROSS DETECTED: tid={tid} "
f"prev_cy={prev_cy:.1f} -> cy={cy:.1f} dir={direction} "
f"seq={seq}"
+ (
" (inherit)"
if inherited_this_frame
else ""
)
f"prev_cy={prev_cy:.1f} -> cy={cy:.1f} "
f"line={line_n} y={line_y} dir={direction}"
)
recent.append((frame_idx, cx))