MCPcopy Create free account
hub / github.com/Tencent/ObjectDetection-OneStageDet / Annotation

Class Annotation

brambox/boxes/annotations/annotation.py:13–143  ·  view source on GitHub ↗

This is a generic annotation class that provides some common functionality all annotations need. It builds upon :class:`~brambox.boxes.box.Box`. Attributes: lost (Boolean): Flag indicating whether the annotation is visible in the image; Default **False** difficult (Boolean)

Source from the content-addressed store, hash-verified

11
12
13class Annotation(b.Box):
14 """ This is a generic annotation class that provides some common functionality all annotations need.
15 It builds upon :class:`~brambox.boxes.box.Box`.
16
17 Attributes:
18 lost (Boolean): Flag indicating whether the annotation is visible in the image; Default **False**
19 difficult (Boolean): Flag indicating whether the annotation is considered difficult; Default **False**
20 occluded (Boolean): Flag indicating whether the annotation is occluded; Default **False**
21 ignore (Boolean): Flag that is used to ignore a bounding box during statistics processing; Default **False**
22 occluded_fraction (Number): value between 0 and 1 that indicates the amount of occlusion (1 = completely occluded); Default **0.0**
23 truncated_fraction (Number): value between 0 and 1 that indicates the amount of truncation (1 = completely truncated); Default **0.0**
24 visible_x_top_left (Number): X pixel coordinate of the top left corner of the bounding box that frames the visible part of the object; Default **0.0**
25 visible_y_top_left (Number): Y pixel coordinate of the top left corner of the bounding box that frames the visible part of the object; Default **0.0**
26 visible_width (Number): Width of the visible bounding box in pixels; Default **0.0**
27 visible_height (Number): Height of the visible bounding box in pixels; Default **0.0**
28
29 Note:
30 The ``visible_x_top_left``, ``visible_y_top_left``, ``visible_width`` and ``visible_height`` attributes
31 are only valid when the ``occluded`` flag is set to **True**.
32 Note:
33 The ``occluded`` flag is actually a property that returns **True** if the ``occluded_fraction`` > **0.0** and **False** if
34 the occluded_fraction equals **0.0**. Thus modifying the ``occluded_fraction`` will affect the ``occluded`` flag and visa versa.
35 """
36 def __init__(self):
37 """ x_top_left,y_top_left,width,height are in pixel coordinates """
38 super(Annotation, self).__init__()
39 self.lost = False # if object is not seen in the image, if true one must ignore this annotation
40 self.difficult = False # if the object is considered difficult
41 self.ignore = False # if true, this bounding box will not be considered in statistics processing
42 self.occluded_fraction = 0.0 # value between 0 and 1 that indicates how much an object is occluded
43 self.truncated_fraction = 0.0 # value between 0 and 1 that indicates how much an object is truncated
44
45 # variables below are only valid if the 'occluded' property is True (occluded_fraction > 0) and
46 # represent a bounding box that indicates the visible area inside the normal bounding box
47 self.visible_x_top_left = 0.0 # x position top left in pixels
48 self.visible_y_top_left = 0.0 # y position top left in pixels
49 self.visible_width = 0.0 # width in pixels
50 self.visible_height = 0.0 # height in pixels
51
52 @property
53 def occluded(self):
54 return self.occluded_fraction > 0.0
55
56 @occluded.setter
57 def occluded(self, val):
58 self.occluded_fraction = float(val)
59
60 @property
61 def truncated(self):
62 return self.truncated_fraction > 0.0
63
64 @truncated.setter
65 def truncated(self, val):
66 self.truncated_fraction = float(val)
67
68 @classmethod
69 def create(cls, obj=None):
70 """ Create an annotation from a string or other box object.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected