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

Function intersection

brambox/boxes/statistics/util.py:131–152  ·  view source on GitHub ↗

Calculate the intersection area between two boxes. Args: a (brambox.boxes.box.Box): First bounding box b (brambox.boxes.box.Box): Second bounding box Returns: Number: Intersection area

(a, b)

Source from the content-addressed store, hash-verified

129
130
131def intersection(a, b):
132 """ Calculate the intersection area between two boxes.
133
134 Args:
135 a (brambox.boxes.box.Box): First bounding box
136 b (brambox.boxes.box.Box): Second bounding box
137
138 Returns:
139 Number: Intersection area
140 """
141 intersection_top_left_x = max(a.x_top_left, b.x_top_left)
142 intersection_top_left_y = max(a.y_top_left, b.y_top_left)
143 intersection_bottom_right_x = min(a.x_top_left + a.width, b.x_top_left + b.width)
144 intersection_bottom_right_y = min(a.y_top_left + a.height, b.y_top_left + b.height)
145
146 intersection_width = intersection_bottom_right_x - intersection_top_left_x
147 intersection_height = intersection_bottom_right_y - intersection_top_left_y
148
149 if intersection_width <= 0 or intersection_height <= 0:
150 return 0.0
151
152 return intersection_width * intersection_height
153
154
155def match_detection_to_annotations(detection, annotations, overlap_threshold, overlap_fn):

Callers 2

iouFunction · 0.85
ioaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected