Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed DivisionByZeroError issue with contours having 0 height or width by excluding them #1380

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed DivisionByZeroError issue with contours having 0 height or widt…
…h by excluding them.
samuelmathew280 committed Nov 13, 2023
commit ad8be9b42c6ae514ea420943502be1300c154e27
2 changes: 1 addition & 1 deletion doctr/models/_utils.py
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ def estimate_orientation(img: np.ndarray, n_ct: int = 50, ratio_threshold_for_li
contours, _ = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

# Sort contours
contours = sorted(contours, key=get_max_width_length_ratio, reverse=True)
contours = sorted([contour for contour in contours if 0 not in cv2.minAreaRect(contour)[1]], key=get_max_width_length_ratio, reverse=True)

angles = []
for contour in contours[:n_ct]: