Skip to content

Commit

Permalink
handle rare error
Browse files Browse the repository at this point in the history
  • Loading branch information
zyddnys committed May 12, 2021
1 parent cfb6033 commit b169b28
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dbnet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ def boxes_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
bitmap = _bitmap.cpu().numpy() # The first channel
pred = pred.cpu().detach().numpy()
height, width = bitmap.shape
contours, _ = cv2.findContours((bitmap * 255).astype(np.uint8), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
try :
contours, _ = cv2.findContours((bitmap * 255).astype(np.uint8), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
except ValueError :
return [], []
num_contours = min(len(contours), self.max_candidates)
boxes = np.zeros((num_contours, 4, 2), dtype=np.int16)
scores = np.zeros((num_contours,), dtype=np.float32)
Expand Down

0 comments on commit b169b28

Please sign in to comment.