File size: 751 Bytes
c446951
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import cv2
import inference
import supervision as sv

box_annotator = sv.BoxAnnotator(color=sv.Color(103, 6, 206))
trace_annotator = sv.TraceAnnotator(color=sv.Color(163, 81, 251), thickness=6)
byte_tracker = sv.ByteTrack()


def render(detections, image):
    detections = sv.Detections.from_roboflow(detections)
    detections = byte_tracker.update_with_detections(detections)
    image = trace_annotator.annotate(scene=image, detections=detections)
    image = box_annotator.annotate(scene=image, detections=detections)

    cv2.imshow("Prediction", image)
    cv2.waitKey(1)


inference.Stream(
    source="people-walking-bw.mp4",
    model="microsoft-coco/9",
    output_channel_order="BGR",
    use_main_thread=True,
    on_prediction=render,
)