levan92 / deep_sort_realtime

A really more real-time adaptation of deep sort
MIT License
167 stars 51 forks source link

yolo detections with your deepsort trackers #11

Closed ayanasser closed 3 years ago

ayanasser commented 3 years ago

I am using yolo : I've get the detection:

            detections = darknet.detect_image(network, class_names, darknet_image, thresh=args.thresh)
            for label, confidence, bbox in detections:

                  left, top, right, bottom = bbox2points(bbox)
                  if big_area_bboxs(left, top, right, bottom, 608, 608) == 0:
                      continue
                  confidence_scores.append(confidence)
                  bboxs.append([left, top, bbox[2], bbox[3]])

then work with the tracker:

        trackers = deepsort.update_tracks(bboxs, frame=frame_resized)
        bb_dict_curr_frame = {}
        print("trackers outside the loop: ", trackers)
        for tracker in trackers:
            print("tracker inside the loop: ", tracker)
            id_num = str(tracker.track_id)
            print("ID num: ", id_num)
            track_bb = tracker.to_tlbr()

And I got this error:

Error is: raw_detections = [d for d in raw_detections if d[0][2] > 0 and d[0][3] > 0] TypeError: 'int' object is not subscriptable

Is there something I missed ? Or the tracker needs another arguments with another shape

ang-zy commented 3 years ago

The format of bboxs is incorrect. bboxs should be a sequence of tuples, where each tuple is ( [left,top,w,h] , confidence, detection_class)

ayanasser commented 3 years ago

Thank you this is worked ^^ For anyone will use yolo with this project you could simply change the order of yolo detection output from: [('person', '73.37', (461.7289733886719, 11.570379257202148, 12.610983848571777, 24.295181274414062))] to :[((461.7289733886719, 11.570379257202148, 12.610983848571777, 24.295181274414062), '73.37', 'person')]

ayanasser commented 3 years ago

You're using Kalman filter inside as well right ?

levan92 commented 3 years ago

yup Kalman filter is used in DeepSORT, you can take a look at the original author's paper for more info. Code can be found at deep_sort/kalman_filter.py.