fix: pass truck centroid to batch manager for state transitions
The legacy batch_mgr.update() method was calling update_truck() with truck_centroid=None, which prevented the batch from transitioning from IDLE to TRUCK_STABILIZING (centroid must be non-None). Now pipeline computes centroid from ROI and passes it through. Verified: old run had 0 cyan pixels (no tracking), new run has 28190 cyan pixels (tracking active, bounding boxes drawn).
This commit is contained in:
1 parent
57afb62542
commit
1e28eb49e2
2 files changed
+7
-1
No files matched your search
+2
-1
@@ -266,10 +266,11 @@ class BatchLifecycleManager:
|
||||
timestamp: float,
|
||||
loading_count: int = 0,
|
||||
unloading_count: int = 0,
|
||||
truck_centroid: tuple[float, float] | None = None,
|
||||
) -> None:
|
||||
"""Legacy update method — kept for backward compatibility."""
|
||||
if self._state in (BatchState.IDLE, BatchState.TRUCK_STABILIZING):
|
||||
self.update_truck(truck_detected, None, timestamp)
|
||||
self.update_truck(truck_detected, truck_centroid, timestamp)
|
||||
elif self._state in (BatchState.COUNTING_SACKS, BatchState.WAITING_FOR_ACTIVITY):
|
||||
self.update_sacks(
|
||||
has_crossing_event=False,
|
||||
|
||||
@@ -184,12 +184,17 @@ def run_pipeline(
|
||||
counter.line_x_end = roi.x2
|
||||
|
||||
# Batch lifecycle
|
||||
truck_centroid = None
|
||||
if roi is not None:
|
||||
truck_centroid = ((roi.x1 + roi.x2) / 2.0, (roi.y1 + roi.y2) / 2.0)
|
||||
|
||||
if frame_idx % truck_det_interval == 0:
|
||||
batch_mgr.update(
|
||||
truck_detected=truck_present,
|
||||
timestamp=timestamp,
|
||||
loading_count=counter.loading_count,
|
||||
unloading_count=counter.unloading_count,
|
||||
truck_centroid=truck_centroid,
|
||||
)
|
||||
|
||||
# Track → Stabilize → Count
|
||||
|
||||
Reference in new issue
Block a user