(img, bbox, pad=2)
| 122 | y2 = min(img.shape[0], y + h + pad) |
| 123 | return img[y1:y2, x1:x2].copy(), (x1, y1, x2, y2) |
| 124 | |
| 125 | |
| 126 | def connected_components(mask, min_area=4): |
| 127 | num_labels, labels, stats, _ = cv2.connectedComponentsWithStats(mask, connectivity=8) |
| 128 | comps = [] |
| 129 | for idx in range(1, num_labels): |
| 130 | x, y, w, h, area = stats[idx] |
| 131 | if area < min_area: |
| 132 | continue |
| 133 | comps.append({'bbox': (int(x), int(y), int(w), int(h)), 'area': int(area)}) |
no outgoing calls
no test coverage detected