MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / load_anno_from_ids

Method load_anno_from_ids

yolox/data/datasets/mot.py:55–88  ·  view source on GitHub ↗
(self, id_)

Source from the content-addressed store, hash-verified

53 return [self.load_anno_from_ids(_ids) for _ids in self.ids]
54
55 def load_anno_from_ids(self, id_):
56 im_ann = self.coco.loadImgs(id_)[0]
57 width = im_ann["width"]
58 height = im_ann["height"]
59 frame_id = im_ann["frame_id"]
60 video_id = im_ann["video_id"]
61 anno_ids = self.coco.getAnnIds(imgIds=[int(id_)], iscrowd=False)
62 annotations = self.coco.loadAnns(anno_ids)
63 objs = []
64 for obj in annotations:
65 x1 = obj["bbox"][0]
66 y1 = obj["bbox"][1]
67 x2 = x1 + obj["bbox"][2]
68 y2 = y1 + obj["bbox"][3]
69 if obj["area"] > 0 and x2 >= x1 and y2 >= y1:
70 obj["clean_bbox"] = [x1, y1, x2, y2]
71 objs.append(obj)
72
73 num_objs = len(objs)
74
75 res = np.zeros((num_objs, 6))
76
77 for ix, obj in enumerate(objs):
78 cls = self.class_ids.index(obj["category_id"])
79 res[ix, 0:4] = obj["clean_bbox"]
80 res[ix, 4] = cls
81 res[ix, 5] = obj["track_id"]
82
83 file_name = im_ann["file_name"] if "file_name" in im_ann else "{:012}".format(id_) + ".jpg"
84 img_info = (height, width, frame_id, video_id, file_name)
85
86 del im_ann, annotations
87
88 return (res, img_info, file_name)
89
90 def load_anno(self, index):
91 return self.annotations[index][0]

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected