vagheshpatel commited on
Commit
2414023
·
verified ·
1 Parent(s): be9360b

Sync person-detection from metro-analytics-catalog

Browse files
Files changed (1) hide show
  1. README.md +17 -8
README.md CHANGED
@@ -196,7 +196,7 @@ Detected persons: 2
196
 
197
  The pipeline below runs the FP16 YOLO26 detector on the sample video via
198
  `gvadetect`, filters detections to the `person` class in a buffer probe using
199
- the DLStreamer Python bindings (`gstgva.VideoFrame`), overlays bounding boxes,
200
  saves the annotated result to `output_dlstreamer.mp4`, and prints the person count per
201
  frame.
202
 
@@ -222,9 +222,8 @@ frame.
222
  import gi
223
 
224
  gi.require_version("Gst", "1.0")
225
- gi.require_version("GstVideo", "1.0")
226
- from gi.repository import Gst
227
- from gstgva import VideoFrame
228
 
229
  Gst.init(None)
230
 
@@ -238,7 +237,8 @@ pipeline_str = (
238
  "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
239
  "device=GPU "
240
  "threshold=0.4 ! queue ! "
241
- "gvawatermark ! videoconvert ! video/x-raw,format=I420 ! "
 
242
  "openh264enc ! h264parse ! "
243
  "mp4mux ! filesink name=sink location=output_dlstreamer.mp4"
244
  )
@@ -247,9 +247,18 @@ pipeline = Gst.parse_launch(pipeline_str)
247
 
248
  def on_buffer(pad, info):
249
  buf = info.get_buffer()
250
- caps = pad.get_current_caps()
251
- frame = VideoFrame(buf, caps=caps)
252
- person_count = sum(1 for r in frame.regions() if r.label() == "person")
 
 
 
 
 
 
 
 
 
253
  if person_count:
254
  print(f"Person count: {person_count}", flush=True)
255
  return Gst.PadProbeReturn.OK
 
196
 
197
  The pipeline below runs the FP16 YOLO26 detector on the sample video via
198
  `gvadetect`, filters detections to the `person` class in a buffer probe using
199
+ the GStreamer Analytics metadata API (`GstAnalytics`), overlays bounding boxes,
200
  saves the annotated result to `output_dlstreamer.mp4`, and prints the person count per
201
  frame.
202
 
 
222
  import gi
223
 
224
  gi.require_version("Gst", "1.0")
225
+ gi.require_version("GstAnalytics", "1.0")
226
+ from gi.repository import Gst, GLib, GstAnalytics
 
227
 
228
  Gst.init(None)
229
 
 
237
  "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
238
  "device=GPU "
239
  "threshold=0.4 ! queue ! "
240
+ "gvawatermark displ-cfg=show-roi=person ! "
241
+ "videoconvert ! video/x-raw,format=I420 ! "
242
  "openh264enc ! h264parse ! "
243
  "mp4mux ! filesink name=sink location=output_dlstreamer.mp4"
244
  )
 
247
 
248
  def on_buffer(pad, info):
249
  buf = info.get_buffer()
250
+ rmeta = GstAnalytics.buffer_get_analytics_relation_meta(buf)
251
+ if rmeta is None:
252
+ return Gst.PadProbeReturn.OK
253
+ person_count = 0
254
+ idx = 1
255
+ while True:
256
+ ok, od = rmeta.get_od_mtd(idx)
257
+ if not ok:
258
+ break
259
+ if GLib.quark_to_string(od.get_obj_type()) == "person":
260
+ person_count += 1
261
+ idx += 1
262
  if person_count:
263
  print(f"Person count: {person_count}", flush=True)
264
  return Gst.PadProbeReturn.OK