MCPcopy Create free account
hub / github.com/MaureenZOU/TSAM / get_bboxes

Method get_bboxes

src/utils/readers.py:351–364  ·  view source on GitHub ↗
(self, i)

Source from the content-addressed store, hash-verified

349 file_.save(filename)
350
351 def get_bboxes(self, i):
352 # TODO: save bbox instead of looking for one
353 mask = self.files[i]
354 mask = ImageOps.invert(mask.convert("L")).convert("1")
355 mask = np.array(mask)
356 image, contours, hier = cv2.findContours(
357 mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
358 bboxes = []
359 for c in contours:
360 # get the bounding rect
361 x, y, w, h = cv2.boundingRect(c)
362 bbox = ((x, y), (x + w - 1, y + h - 1))
363 bboxes.append(bbox)
364 return bboxes
365
366 def get_bbox(self, i):
367 # TODO: save bbox instead of looking for one

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected