Simplify `remove_zero_areas()` function (#3060)

single_channel
Laughing 2 years ago committed by GitHub
parent 8940a27bdb
commit 31281400dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -209,9 +209,10 @@ class Instances:
"""Convert bounding box format."""
self._bboxes.convert(format=format)
@property
def bbox_areas(self):
"""Calculate the area of bounding boxes."""
self._bboxes.areas()
return self._bboxes.areas()
def scale(self, scale_w, scale_h, bbox_only=False):
"""this might be similar with denormalize func but without normalized sign."""
@ -328,9 +329,9 @@ class Instances:
def remove_zero_area_boxes(self):
"""Remove zero-area boxes, i.e. after clipping some boxes may have zero width or height. This removes them."""
good = self._bboxes.areas() > 0
good = self.bbox_areas > 0
if not all(good):
self._bboxes = Bboxes(self._bboxes.bboxes[good], format=self._bboxes.format)
self._bboxes = self._bboxes[good]
if len(self.segments):
self.segments = self.segments[good]
if self.keypoints is not None:

Loading…
Cancel
Save