sort icon indicating copy to clipboard operation
sort copied to clipboard

SORT / DSORT for live video feed

Open utsembedded opened this issue 5 years ago • 2 comments

HI ,

How can i use this application to track objects using my camera with live feed .

utsembedded avatar Aug 10 '20 13:08 utsembedded

Hello, Assuming your object detection works, you can use this skeleton code to implement tracking on a live video:

import sort, cv2, numpy

def main():

    cap = cv2.VideoCapture(0)   # Open the webcam feed

    tracker = sort.Sort(max_age=0.5, min_hits=0.5, iou_threshold=0.5)

    # Load your object detector network here

    while True:

        img = cap.read()

        # perform your detections + NMS here
        # Store the detections in the Sort acceptable format. E.g. for Darknet, 
        # I get bounding boxes + confidence scores

        # Here I am assuming detections is formatted as a numpy array of: [[x1, y1, x2, y2, confidence]].
        tracks = tracker.update(detections)

        # tracks gives you a 2D numpy array in the format [[x1, y1, x2, y2, tracked_id]]

        # Add your display code here
    cap.release()):

software3daerospace avatar Apr 14 '21 19:04 software3daerospace

But are we making detections on every single frame? then what is the point of using tracker? How can we get updating bounding box locations using tracker without passing detections?

Momilijaz96 avatar Nov 16 '21 00:11 Momilijaz96