minas2025 commited on
Commit
668fd03
·
verified ·
1 Parent(s): 692d46f

v2-compatible class filter

Browse files
Files changed (1) hide show
  1. circle_bibi.py +10 -3
circle_bibi.py CHANGED
@@ -116,6 +116,7 @@ def main():
116
  ap.add_argument("--gpu", action="store_true")
117
  ap.add_argument("--camera", action="store_true")
118
  ap.add_argument("--stride", type=int, default=1, help="process every Nth frame")
 
119
  ap.add_argument("--no-label", action="store_true", help="circle only, no text")
120
  args = ap.parse_args()
121
 
@@ -125,9 +126,11 @@ def main():
125
 
126
  cap, proc, fps, w, h = open_source(args)
127
  writer = None
128
- if not args.camera:
129
  fourcc = cv2.VideoWriter_fourcc(*"mp4v")
130
  writer = cv2.VideoWriter(args.output, fourcc, fps, (w, h))
 
 
131
 
132
  prev = None # smoothed (cx, cy, r)
133
  cache = None # last confirmed visual (cx, cy, r, pct) for skipped frames
@@ -145,6 +148,8 @@ def main():
145
  device=0 if args.gpu else "cpu")[0]
146
  target = None
147
  for b in r.boxes:
 
 
148
  x1, y1, x2, y2 = b.xyxy[0].tolist()
149
  conf = float(b.conf[0])
150
  # match full-frame faces to this box by IoU (SCRFD is unreliable
@@ -182,8 +187,10 @@ def main():
182
  if writer:
183
  writer.write(frame)
184
  kept += 1
185
- elif cv2.waitKey(1) & 0xFF == ord("q"):
186
- break
 
 
187
  if cap is not None:
188
  cap.release()
189
  if proc is not None:
 
116
  ap.add_argument("--gpu", action="store_true")
117
  ap.add_argument("--camera", action="store_true")
118
  ap.add_argument("--stride", type=int, default=1, help="process every Nth frame")
119
+ ap.add_argument("--live", action="store_true", help="show on screen, no output file")
120
  ap.add_argument("--no-label", action="store_true", help="circle only, no text")
121
  args = ap.parse_args()
122
 
 
126
 
127
  cap, proc, fps, w, h = open_source(args)
128
  writer = None
129
+ if not (args.camera or args.live):
130
  fourcc = cv2.VideoWriter_fourcc(*"mp4v")
131
  writer = cv2.VideoWriter(args.output, fourcc, fps, (w, h))
132
+ if args.live or args.camera:
133
+ cv2.namedWindow("BIG YAHU RADAR (q to quit)", cv2.WINDOW_NORMAL)
134
 
135
  prev = None # smoothed (cx, cy, r)
136
  cache = None # last confirmed visual (cx, cy, r, pct) for skipped frames
 
148
  device=0 if args.gpu else "cpu")[0]
149
  target = None
150
  for b in r.boxes:
151
+ if hasattr(b, "cls") and int(b.cls[0]) != 0:
152
+ continue # v2 model: class 1 = notbibi, never draw it
153
  x1, y1, x2, y2 = b.xyxy[0].tolist()
154
  conf = float(b.conf[0])
155
  # match full-frame faces to this box by IoU (SCRFD is unreliable
 
187
  if writer:
188
  writer.write(frame)
189
  kept += 1
190
+ else:
191
+ cv2.imshow("BIG YAHU RADAR (q to quit)", frame)
192
+ if cv2.waitKey(max(1, int(1000/max(fps, 5)))) & 0xFF == ord("q"):
193
+ break
194
  if cap is not None:
195
  cap.release()
196
  if proc is not None: