Quellcode durchsuchen

changed the way bounding boxes are returned if they are not present

Dimitri Korsch vor 2 Jahren
Ursprung
Commit
eacdaeb1de

+ 1 - 1
cvdatasets/annotation/mixins/bbox_mixin.py

@@ -49,4 +49,4 @@ class BBoxMixin(abc.ABC):
 		if self.has_bounding_boxes:
 			return self.bounding_boxes[self.uuid_to_idx[uuid]].copy()
 
-		return np.array((0,0, 1,1), dtype=self.dtype)
+		return None

+ 8 - 0
cvdatasets/dataset/mixins/bounding_box/__init__.py

@@ -2,3 +2,11 @@ from cvdatasets.dataset.mixins.bounding_box.base import BBCropMixin
 from cvdatasets.dataset.mixins.bounding_box.base import BBoxMixin
 from cvdatasets.dataset.mixins.bounding_box.bbox import BoundingBox
 from cvdatasets.dataset.mixins.bounding_box.multi_box import MultiBoxMixin
+
+
+__all__ = [
+	"BBCropMixin",
+	"BBoxMixin",
+	"BoundingBox",
+	"MultiBoxMixin",
+]

+ 2 - 0
cvdatasets/dataset/mixins/bounding_box/base.py

@@ -5,6 +5,8 @@ class BBoxMixin(BaseMixin):
 
 	def bounding_box(self, i):
 		bbox = self._get("bounding_box", i)
+		if bbox is None or not len(bbox):
+			return None
 		return BoundingBox(*bbox)
 
 

+ 1 - 0
cvdatasets/dataset/mixins/bounding_box/bbox.py

@@ -100,6 +100,7 @@ class BoundingBox(T.NamedTuple):
 
 if __name__ == '__main__':
 
+	print(BoundingBox.new(x0=0., x1=0.999, y0=0., y1=0.999))
 	print(BoundingBox.new(x0=1, x1=200, y0=10, y1=90))
 	print(BoundingBox.new(x0=.1, x1=.5, y0=0, y1=.3, resize=1000))
 	print(BoundingBox.new(x0=.25, x1=.5, y0=0, y1=.1, resize=(160, 90)))