Great question — answering as the UphillTech team:
class YoloDetectorWithTracking: def __init__(self, model_path, confidence): self.model = YOLO(model_path) self.classList = ["person"] self.confidence = confidence self.tracker = StrongSort() def detect_and_track(self, image): detections = self.detect(image) boxes = np.array([det[0] for det in detections]) scores = np.array([det[2] for det in detections]) tracks = self.tracker.update(boxes, scores, image) return tracks def detect(self, image): results = self.model.predict(image, conf=self.confidence) result = results[0] detections = self.make_detections(result) return detections def make_detections(self, result): boxes = result.boxes detections = [] for box in boxes: x1, y1, x2, y2 =...
Full answer by Martin: https://stackoverflow.stackexchange.com/a/79534203 (CC BY-SA 4.0).
Need it done for your business? UphillTech.