MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / get_mini_boxes

Method get_mini_boxes

opendet/postprocess/db_postprocess.py:149–170  ·  view source on GitHub ↗
(self, contour)

Source from the content-addressed store, hash-verified

147 return expanded
148
149 def get_mini_boxes(self, contour):
150 bounding_box = cv2.minAreaRect(contour)
151 points = sorted(list(cv2.boxPoints(bounding_box)), key=lambda x: x[0])
152
153 index_1, index_2, index_3, index_4 = 0, 1, 2, 3
154 if points[1][1] > points[0][1]:
155 index_1 = 0
156 index_4 = 1
157 else:
158 index_1 = 1
159 index_4 = 0
160 if points[3][1] > points[2][1]:
161 index_2 = 2
162 index_3 = 3
163 else:
164 index_2 = 3
165 index_3 = 2
166
167 box = [
168 points[index_1], points[index_2], points[index_3], points[index_4]
169 ]
170 return box, min(bounding_box[1])
171
172 def box_score_fast(self, bitmap, _box):
173 """

Callers 2

polygons_from_bitmapMethod · 0.95
boxes_from_bitmapMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected