hb-setosys commited on
Commit
d7f6c17
·
verified ·
1 Parent(s): 1fdf523

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -44,6 +44,7 @@ def count_unique_trucks(video_path):
44
  if not cap.isOpened():
45
  return {"Error": "Unable to open video file."}
46
 
 
47
  unique_truck_ids = set()
48
  truck_history = {}
49
 
@@ -64,6 +65,9 @@ def count_unique_trucks(video_path):
64
 
65
  frame_count = 0
66
 
 
 
 
67
  while True:
68
  ret, frame = cap.read()
69
  if not ret:
@@ -124,6 +128,7 @@ def count_unique_trucks(video_path):
124
  cap.release()
125
  return {"Total Unique Trucks": len(unique_truck_ids)}
126
 
 
127
  # Gradio UI function
128
  def analyze_video(video_file):
129
  result = count_unique_trucks(video_file)
 
44
  if not cap.isOpened():
45
  return {"Error": "Unable to open video file."}
46
 
47
+ # Reset variables at the start of each analysis
48
  unique_truck_ids = set()
49
  truck_history = {}
50
 
 
65
 
66
  frame_count = 0
67
 
68
+ # Reinitialize the tracker to clear any previous state
69
+ tracker = Sort()
70
+
71
  while True:
72
  ret, frame = cap.read()
73
  if not ret:
 
128
  cap.release()
129
  return {"Total Unique Trucks": len(unique_truck_ids)}
130
 
131
+
132
  # Gradio UI function
133
  def analyze_video(video_file):
134
  result = count_unique_trucks(video_file)