Skip to content

Commit

Permalink
Implement classifier for double_white_circle
Browse files Browse the repository at this point in the history
  • Loading branch information
brawer committed Apr 9, 2024
1 parent 43acc78 commit f9caae8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
6 changes: 6 additions & 0 deletions classify/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f9caae8

Please sign in to comment.