|
|
|
@ -35,6 +35,7 @@ class DBPostProcess(object):
|
|
|
|
|
self.thresh = params['thresh']
|
|
|
|
|
self.box_thresh = params['box_thresh']
|
|
|
|
|
self.max_candidates = params['max_candidates']
|
|
|
|
|
self.unclip_ratio = params['unclip_ratio']
|
|
|
|
|
self.min_size = 3
|
|
|
|
|
|
|
|
|
|
def boxes_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
|
|
|
|
@ -46,7 +47,8 @@ class DBPostProcess(object):
|
|
|
|
|
bitmap = _bitmap
|
|
|
|
|
height, width = bitmap.shape
|
|
|
|
|
|
|
|
|
|
outs = cv2.findContours((bitmap * 255).astype(np.uint8), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
|
|
|
|
|
outs = cv2.findContours((bitmap * 255).astype(np.uint8), cv2.RETR_LIST,
|
|
|
|
|
cv2.CHAIN_APPROX_SIMPLE)
|
|
|
|
|
if len(outs) == 3:
|
|
|
|
|
img, contours, _ = outs[0], outs[1], outs[2]
|
|
|
|
|
elif len(outs) == 2:
|
|
|
|
@ -83,7 +85,8 @@ class DBPostProcess(object):
|
|
|
|
|
scores[index] = score
|
|
|
|
|
return boxes, scores
|
|
|
|
|
|
|
|
|
|
def unclip(self, box, unclip_ratio=2.0):
|
|
|
|
|
def unclip(self, box):
|
|
|
|
|
unclip_ratio = self.unclip_ratio
|
|
|
|
|
poly = Polygon(box)
|
|
|
|
|
distance = poly.area * unclip_ratio / poly.length
|
|
|
|
|
offset = pyclipper.PyclipperOffset()
|
|
|
|
|