Create a detection from a string or other box object. Args: obj (Box or string, optional): Bounding box object to copy attributes from or string to deserialize Note: The obj can be both an :class:`~brambox.boxes.annotations.Annotation` or a :class:`~brambox
(cls, obj=None)
| 24 | |
| 25 | @classmethod |
| 26 | def create(cls, obj=None): |
| 27 | """ Create a detection from a string or other box object. |
| 28 | |
| 29 | Args: |
| 30 | obj (Box or string, optional): Bounding box object to copy attributes from or string to deserialize |
| 31 | |
| 32 | Note: |
| 33 | The obj can be both an :class:`~brambox.boxes.annotations.Annotation` or a :class:`~brambox.boxes.detections.Detection`. |
| 34 | For Detections the confidence score is copied over, for Annotations it is set to 1. |
| 35 | """ |
| 36 | instance = super(Detection, cls).create(obj) |
| 37 | |
| 38 | if obj is None: |
| 39 | return instance |
| 40 | |
| 41 | if isinstance(obj, Detection): |
| 42 | instance.confidence = obj.confidence |
| 43 | elif isinstance(obj, anno.Annotation): |
| 44 | instance.confidence = 1.0 |
| 45 | |
| 46 | return instance |
| 47 | |
| 48 | def __repr__(self): |
| 49 | """ Unambiguous representation """ |