MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / crop_bbox

Function crop_bbox

app/services/tenvision_adapter.py:124–130  ·  view source on GitHub ↗
(img, bbox, pad=2)

Source from the content-addressed store, hash-verified

122 y2 = min(img.shape[0], y + h + pad)
123 return img[y1:y2, x1:x2].copy(), (x1, y1, x2, y2)
124
125
126def 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)})

Callers 3

recognize_prompt_boxesFunction · 0.85
split_ocr_itemFunction · 0.85
recognize_yellow_boxesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected