working
This commit is contained in:
parent
a519dea130
commit
16842186c7
2 changed files with 24 additions and 11 deletions
|
|
@ -109,6 +109,10 @@ def main_multi_stream():
|
|||
start_time = time.time()
|
||||
stats_lock = threading.Lock()
|
||||
|
||||
# Buffer for latest frames (for display in main thread)
|
||||
latest_frames = {}
|
||||
frames_lock = threading.Lock()
|
||||
|
||||
# Create windows for each stream if display enabled
|
||||
if ENABLE_DISPLAY:
|
||||
for stream_id, _ in camera_urls:
|
||||
|
|
@ -121,13 +125,6 @@ def main_multi_stream():
|
|||
"""Callback for tracking results - called automatically per stream"""
|
||||
nonlocal total_results
|
||||
|
||||
# Debug: Check if we have frame tensor
|
||||
has_frame = result.frame_tensor is not None
|
||||
frame_shape = result.frame_tensor.shape if has_frame else None
|
||||
print(
|
||||
f"[CALLBACK] Got result for {result.stream_id}, has_frame={has_frame}, shape={frame_shape}, detections={len(result.detections)}"
|
||||
)
|
||||
|
||||
with stats_lock:
|
||||
total_results += 1
|
||||
stream_id = result.stream_id
|
||||
|
|
@ -203,8 +200,9 @@ def main_multi_stream():
|
|||
2,
|
||||
)
|
||||
|
||||
# Display
|
||||
cv2.imshow(stream_id, frame_bgr)
|
||||
# Store frame for display in main thread (OpenCV requires this)
|
||||
with frames_lock:
|
||||
latest_frames[stream_id] = frame_bgr
|
||||
|
||||
# Connect all streams in parallel using threads
|
||||
print(f"\n[3/3] Connecting {len(camera_urls)} streams in parallel...")
|
||||
|
|
@ -259,6 +257,11 @@ def main_multi_stream():
|
|||
# Keep main thread alive and process OpenCV events
|
||||
while True:
|
||||
if ENABLE_DISPLAY:
|
||||
# Display latest frames from all streams
|
||||
with frames_lock:
|
||||
for stream_id, frame_bgr in latest_frames.items():
|
||||
cv2.imshow(stream_id, frame_bgr)
|
||||
|
||||
# Process OpenCV events to keep windows responsive
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue