MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / DetBoxGT

Class DetBoxGT

PATH/core/solvers/utils/detools/box.py:271–328  ·  view source on GitHub ↗

:class: bounding box for detection groundtruth, inherited from BoxBase :ivar int ign: if the bounding box should be ignored or not. 0 for NOT ignored (default); 1 for ignored. :ivar float occ: occlusion rate of the bounding box (default 0.0), e.g., occ=0.6 means 60% of the box is invisi

Source from the content-addressed store, hash-verified

269
270
271class DetBoxGT(BoxBase):
272 """
273 :class: bounding box for detection groundtruth, inherited from BoxBase
274 :ivar int ign: if the bounding box should be ignored or not. 0 for NOT ignored (default); 1 for ignored.
275 :ivar float occ: occlusion rate of the bounding box (default 0.0), e.g., occ=0.6 means 60% of the box is invisible
276 :ivar int matched: if matched with a detection result. 0 for unmatched (default); 1 for matched
277 """
278 def __init__(self, x=0.0, y=0.0, w=0.0, h=0.0, tag=None, ign=0, occ=0.0, color=None):
279 super(DetBoxGT, self).__init__(x, y, w, h, tag)
280 self.ign = ign
281 self.occ = occ
282 self.matched = 0 # 0 for unmatched / 1 for matched
283 self.color = color
284
285 def parseOdf(self, odf):
286 """
287 :meth: read the object from a dict
288 :param dict odf: a dict with "box", "score", "occ" and "extra.ignore" keys, e.g., odf = {"box": [5,5,20,50], "tag": "person", "occ": 0.6, "extra": {"ignore": 0}}
289 """
290 super(DetBoxGT, self).parseOdf(odf)
291 if "extra" in odf and "ignore" in odf["extra"]:
292 self.ign = odf["extra"]["ignore"]
293 if "occ" in odf:
294 self.occ = odf["occ"]
295 self.matched = 0
296 def parseOdfbyname(self,odf,name):
297 #pdb.set_trace()
298 #params = {'odf':odf,'name':name}
299 super(DetBoxGT,self).parseOdfbyname(odf,name)
300 if "extra" in odf and "ignore" in odf["extra"]:
301 self.ign = odf["extra"]["ignore"]
302 if "occ" in odf:
303 self.occ = odf["occ"]
304 self.matched = 0
305
306 def dumpOdf(self):
307 """
308 :meth: dump the object into a dict
309 :return: a dict with "box", "score", "occ" and "extra.ignore" keys
310 """
311 odf = super(DetBoxGT, self).dumpOdf()
312 odf["extra"] = {"ignore": self.ign}
313 odf["occ"] = self.occ
314 return odf
315
316 def _getDrawColor(self):
317 """
318 :meth: get the color for groundtruth box. Red for unmatched (self.matched=0 & self.ign=0); cyan for matched (self.matched=1 & self.ign=0); yellow for ignored groundtruth (self.ign=1)
319 """
320 if self.color is not None:
321 return self.color
322 if self.ign == 1:
323 color = (0, 255, 255) # yellow for ignored gt
324 elif self.matched == 0:
325 color = (0, 0, 255) # red for unmatched gt
326 elif self.matched == 1:
327 color = (255, 255, 0) # cyan for matched gt
328 return color

Callers 3

draw_img_boxesMethod · 0.85
parse_gt_boxesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected