for i, cnt in enumerate(objects):
# Store coordinates for labels
x_list.append(objects[i][0][0][0])
y_list.append(objects[i][0][0][1])
# Draw segments one by one to group segment tips together
finding_tips_img = np.zeros(segmented_img.shape[:2], np.uint8)
cv2.drawContours(finding_tips_img, objects, i, (255, 255, 255), 1, lineType=8)
segment_tips = find_tips(finding_tips_img)
tip_objects, tip_hierarchies = find_objects(segment_tips, segment_tips)
points = []
if not len(tip_objects) == 2:
fatal_error("Too many tips found per segment, try pruning again")
for t in tip_objects:
# Gather pairs of coordinates
x, y = t.ravel()
coord = (x, y)
points.append(coord)
你要看你调用的参数是否正确