fix: realtime multi cam
This commit is contained in:
parent
593611cdb7
commit
bf7b68edb1
1 changed files with 34 additions and 18 deletions
|
|
@ -266,7 +266,7 @@ def main_multi_stream():
|
||||||
conn = manager.connect_stream(
|
conn = manager.connect_stream(
|
||||||
rtsp_url=rtsp_url,
|
rtsp_url=rtsp_url,
|
||||||
stream_id=stream_id,
|
stream_id=stream_id,
|
||||||
buffer_size=30
|
buffer_size=5
|
||||||
)
|
)
|
||||||
connections[stream_id] = conn
|
connections[stream_id] = conn
|
||||||
print(f"✓ Connected: {stream_id}")
|
print(f"✓ Connected: {stream_id}")
|
||||||
|
|
@ -289,10 +289,19 @@ def main_multi_stream():
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Simple approach: iterate over first connection's results
|
# Merge all result queues from all connections
|
||||||
# In production, you'd properly merge all result streams
|
import queue as queue_module
|
||||||
|
|
||||||
|
running = True
|
||||||
|
while running:
|
||||||
|
# Poll all connection queues (non-blocking)
|
||||||
|
got_result = False
|
||||||
for conn in connections.values():
|
for conn in connections.values():
|
||||||
for result in conn.tracking_results():
|
try:
|
||||||
|
# Non-blocking get from each connection's queue
|
||||||
|
result = conn.result_queue.get_nowait()
|
||||||
|
got_result = True
|
||||||
|
|
||||||
total_results += 1
|
total_results += 1
|
||||||
stream_id = result.stream_id
|
stream_id = result.stream_id
|
||||||
|
|
||||||
|
|
@ -310,6 +319,13 @@ def main_multi_stream():
|
||||||
s_fps = stats['count'] / s_elapsed if s_elapsed > 0 else 0
|
s_fps = stats['count'] / s_elapsed if s_elapsed > 0 else 0
|
||||||
print(f" {sid}: {stats['count']} ({s_fps:.1f} FPS)")
|
print(f" {sid}: {stats['count']} ({s_fps:.1f} FPS)")
|
||||||
|
|
||||||
|
except queue_module.Empty:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Small sleep if no results to avoid busy loop
|
||||||
|
if not got_result:
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print(f"\n✓ Interrupted")
|
print(f"\n✓ Interrupted")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue