diff --git a/classify/README.md b/classify/README.md index 3976e7f..358f264 100644 --- a/classify/README.md +++ b/classify/README.md @@ -10,8 +10,8 @@ $ venv/bin/python3 -m classify cadasym-0.1.3.zip Symbol Class Precision Recall -------------------------------------- black_dot 87.9 100.0 -double_white_circle 0.0 0.0 -other 77.9 93.1 +double_white_circle 100.0 68.8 +other 85.5 93.1 white_circle 94.2 96.7 ``` diff --git a/classify/classify.py b/classify/classify.py index c392cf4..6846a37 100644 --- a/classify/classify.py +++ b/classify/classify.py @@ -43,6 +43,12 @@ def classify_contour(img, contours, hierarchy, c): parent_index = hierarchy[0][c][3] parent = contours[parent_index] if parent_index >= 0 else None x, y, r = contour_circle(contour) + if white and not has_holes and between(r, 7.0, 19.0): + has_black = any(has_circle(img, x, y, r + i, 0) for i in [2]) + has_white = any(has_circle(img, x, y, r + i, 255) for i in [10, 11]) + has_black_2 = any(has_circle(img, x, y, r + i, 0) for i in [15]) + if has_black and has_white and has_black_2: + return "double_white_circle" if white and not has_holes and between(r, 7.5, 15.5): pw, ph = cv2.minAreaRect(parent)[1] if pw > 150 or ph > 150: