Fix RATE start from big Number
This commit is contained in:
1 parent
641da193d1
commit
05a85c8f8f
1 file changed
+7
-1
@@ -10,6 +10,7 @@ import csv
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
|
from collections import deque
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ MIN_DURATION_PER_BATCH = int(os.getenv("MIN_DURATION_PER_BATCH", "60"))
|
|||||||
EXPORT_CSV = os.getenv("EXPORT_CSV", "true").lower() == "true"
|
EXPORT_CSV = os.getenv("EXPORT_CSV", "true").lower() == "true"
|
||||||
CROSS_CSV = os.getenv("CROSS_CSV", f"{OUTPUT_DIR}/batch_crossings.csv")
|
CROSS_CSV = os.getenv("CROSS_CSV", f"{OUTPUT_DIR}/batch_crossings.csv")
|
||||||
|
|
||||||
|
RATE_WINDOW_SEC = int(os.getenv("RATE_WINDOW_SEC", "60"))
|
||||||
WARMUP_FRAMES = int(os.getenv("WARMUP_FRAMES", "30"))
|
WARMUP_FRAMES = int(os.getenv("WARMUP_FRAMES", "30"))
|
||||||
RECONNECT_DELAY_SEC = int(os.getenv("RECONNECT_DELAY_SEC", "3"))
|
RECONNECT_DELAY_SEC = int(os.getenv("RECONNECT_DELAY_SEC", "3"))
|
||||||
MAX_RECONNECT_ATTEMPTS = int(os.getenv("MAX_RECONNECT_ATTEMPTS", "0"))
|
MAX_RECONNECT_ATTEMPTS = int(os.getenv("MAX_RECONNECT_ATTEMPTS", "0"))
|
||||||
@@ -1016,6 +1018,7 @@ def run():
|
|||||||
frame_idx = 0
|
frame_idx = 0
|
||||||
inf_ms = 0.0
|
inf_ms = 0.0
|
||||||
video_writer = None
|
video_writer = None
|
||||||
|
crossing_times = deque()
|
||||||
|
|
||||||
cap, w, h, fps = connect_stream(SOURCE)
|
cap, w, h, fps = connect_stream(SOURCE)
|
||||||
if cap is None:
|
if cap is None:
|
||||||
@@ -1162,6 +1165,7 @@ def run():
|
|||||||
ayam_crossed_frame = True
|
ayam_crossed_frame = True
|
||||||
if started_new:
|
if started_new:
|
||||||
batch_started_frame = True
|
batch_started_frame = True
|
||||||
|
crossing_times.append(mono)
|
||||||
ayam_cross_flash[tid] = CROSS_FLASH_FRAMES
|
ayam_cross_flash[tid] = CROSS_FLASH_FRAMES
|
||||||
popups.append(
|
popups.append(
|
||||||
{
|
{
|
||||||
@@ -1219,7 +1223,9 @@ def run():
|
|||||||
batch_num = store.current_batch_number or 0
|
batch_num = store.current_batch_number or 0
|
||||||
batch_count = store.current_batch_count
|
batch_count = store.current_batch_count
|
||||||
display_total = store.display_total()
|
display_total = store.display_total()
|
||||||
rate = (display_total / elapsed * 60) if elapsed > 0 else 0.0
|
while crossing_times and mono - crossing_times[0] > RATE_WINDOW_SEC:
|
||||||
|
crossing_times.popleft()
|
||||||
|
rate = (len(crossing_times) / RATE_WINDOW_SEC * 60) if crossing_times else 0.0
|
||||||
|
|
||||||
draw_elegant_counting_line(frame, line_x, h, line_pulse)
|
draw_elegant_counting_line(frame, line_x, h, line_pulse)
|
||||||
draw_hero_count(frame, line_x, h, batch_count, count_pulse)
|
draw_hero_count(frame, line_x, h, batch_count, count_pulse)
|
||||||
|
|||||||
Reference in new issue
Block a user