Views
No views yet
| Property | Value |
|---|---|
| Category | Object Detection (Crowd / Person Counting) |
| Base Model | YOLO26 (Ultralytics) |
| Source Framework | PyTorch (Ultralytics) |
| Supported Precisions | FP32, FP16, INT8 (mixed-precision) |
| Inference Engine | OpenVINO |
| Hardware | CPU, GPU, NPU |
| Detected Class | person (COCO class 0) |
person class.
Typical Metro deployments include:yolo26n, yolo26s, yolo26m, yolo26l, yolo26x.
Smaller variants (yolo26n, yolo26s) are recommended for high-FPS edge deployment; larger variants improve recall in dense crowds.1python3 -m venv .venv --system-site-packages
2source .venv/bin/activateNote: The--system-site-packagesflag is required so the virtual environment can access the system-installed OpenVINO and DLStreamer Python packages.
1chmod +x export_and_quantize.sh
2./export_and_quantize.sh1./export_and_quantize.sh yolo26n FP32 # full-precision
2./export_and_quantize.sh yolo26n INT8 # quantized
3./export_and_quantize.sh yolo26s # larger variant, default FP16yolo26n with any variant (yolo26s, yolo26m, yolo26l, yolo26x).
The second argument selects the precision (FP32, FP16, INT8); the default is FP16.openvino, ultralytics; adds nncf for INT8).test.jpg) and a sample test video (test_video.mp4).yolo26n_openvino_model/ -- FP32 or FP16 OpenVINO IR model directory.yolo26n_crowd_int8.xml / yolo26n_crowd_int8.bin -- INT8 quantized model (only when INT8 is selected).| Precision | CPU | GPU | NPU |
|---|---|---|---|
| FP32 | Yes | Yes | No |
| FP16 | Yes | Yes | Yes |
| INT8 | Yes | Yes | Yes |
Note: The INT8 calibration uses the bundled sample image. For production accuracy, replace it with a representative set of frames from the target deployment site.
person class, and
reports the crowd count for a single image.1import cv2
2import numpy as np
3import openvino as ov
4
5PERSON_CLASS_ID = 0
6CONF_THRESHOLD = 0.4
7INPUT_SIZE = 640
8
9core = ov.Core()
10model = core.read_model("yolo26n_openvino_model/yolo26n.xml")
11compiled = core.compile_model(model, "CPU") # or "GPU", "NPU"
12
13image = cv2.imread("test.jpg")
14h0, w0 = image.shape[:2]
15
16# Preprocess: letterbox-free resize for simplicity.
17blob = cv2.resize(image, (INPUT_SIZE, INPUT_SIZE))
18blob = cv2.cvtColor(blob, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
19blob = blob.transpose(2, 0, 1)[np.newaxis, ...] # NCHW
20
21# YOLO26 end-to-end output: [1, 300, 6] = [x1, y1, x2, y2, confidence, class_id]
22# No NMS is needed -- YOLO26 is natively end-to-end.
23output = compiled([blob])[compiled.output(0)][0]
24mask = (output[:, 4] >= CONF_THRESHOLD) & (output[:, 5].astype(int) == PERSON_CLASS_ID)
25dets = output[mask]
26
27sx, sy = w0 / INPUT_SIZE, h0 / INPUT_SIZE
28crowd_count = len(dets)
29print(f"Detected persons: {crowd_count}")
30
31for det in dets:
32 x1 = int(det[0] * sx)
33 y1 = int(det[1] * sy)
34 x2 = int(det[2] * sx)
35 y2 = int(det[3] * sy)
36 cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
37
38cv2.putText(
39 image, f"Crowd count: {crowd_count}", (10, 30),
40 cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 0), 2,
41)
42cv2.imwrite("output_openvino.jpg", image)export_and_quantize.sh script downloads test.jpg automatically.
Re-run the OpenVINO sample above.
The script reads test.jpg, prints the crowd count to the console, and writes the annotated frame to output_openvino.jpg.Detected persons: 4output_openvino.jpg is the same image with a green bounding box drawn around each detected person and the text Crowd count: 4 overlaid in the top-left corner.Tip: For production testing, replace the bundledtest.jpgwith an image from your target deployment site showing a representative crowd density.

gvadetect, filters detections to the person class in a buffer probe using
the GStreamer Analytics metadata API (GstAnalytics), overlays bounding boxes,
saves the annotated result to output_dlstreamer.mp4, and prints the crowd count per
frame.Notes on running this sample:
Use the FP16 IR (yolo26n_openvino_model/yolo26n.xml). On DLStreamer 2026.0.0,gvadetectcannot auto-derive a YOLO post-processor from the INT8 model produced by the bundled script. To use the INT8 model, supply a matchingmodel-procJSON. Class names are read automatically from the model's embeddedmetadata.yamlby DLStreamer 2026.0+ -- no externallabels-fileis required. Filtering withobject-class=persondirectly ongvadetectis rejected wheninference-regionisfull-frame(the default), so the sample filters by detection label in the buffer probe instead. ExportPYTHONPATHso the DLStreamer Python module is importable:bash1source /opt/intel/openvino_2026/setupvars.sh 2source /opt/intel/dlstreamer/scripts/setup_dls_env.sh 3export PYTHONPATH=/opt/intel/dlstreamer/python:\ 4/opt/intel/dlstreamer/gstreamer/lib/python3/dist-packages:${PYTHONPATH:-}
1import gi
2
3gi.require_version("Gst", "1.0")
4gi.require_version("GstAnalytics", "1.0")
5from gi.repository import Gst, GLib, GstAnalytics
6
7Gst.init([])
8
9INPUT_VIDEO = "test_video.mp4"
10
11# For CPU: change device=GPU to device=CPU.
12# For NPU: change device=GPU to device=NPU (batch-size=1, nireq=4 recommended).
13pipeline_str = (
14 f"filesrc location={INPUT_VIDEO} ! decodebin3 ! "
15 "videoconvert ! "
16 "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
17 "device=GPU "
18 "threshold=0.4 ! queue ! "
19 "gvawatermark displ-cfg=show-roi=person ! "
20 "videoconvert ! video/x-raw,format=I420 ! "
21 "openh264enc ! h264parse ! "
22 "mp4mux ! filesink name=sink location=output_dlstreamer.mp4"
23)
24pipeline = Gst.parse_launch(pipeline_str)
25
26sink = pipeline.get_by_name("sink")
27sink_pad = sink.get_static_pad("sink")
28
29
30def on_buffer(pad, info):
31 buf = info.get_buffer()
32 rmeta = GstAnalytics.buffer_get_analytics_relation_meta(buf)
33 if rmeta is None:
34 return Gst.PadProbeReturn.OK
35 crowd_count = 0
36 idx = 1
37 while True:
38 ok, od = rmeta.get_od_mtd(idx)
39 if not ok:
40 break
41 if GLib.quark_to_string(od.get_obj_type()) == "person":
42 crowd_count += 1
43 idx += 1
44 if crowd_count:
45 print(f"Crowd count: {crowd_count}", flush=True)
46 return Gst.PadProbeReturn.OK
47
48
49sink_pad.add_probe(Gst.PadProbeType.BUFFER, on_buffer)
50
51pipeline.set_state(Gst.State.PLAYING)
52bus = pipeline.get_bus()
53bus.timed_pop_filtered(
54 Gst.CLOCK_TIME_NONE,
55 Gst.MessageType.EOS | Gst.MessageType.ERROR,
56)
57pipeline.set_state(Gst.State.NULL)
device=GPU -- default in the sample code.device=CPU -- change device=GPU to device=CPU.device=NPU -- change device=GPU to device=NPU; use batch-size=1 and nireq=4 for best NPU utilization.