pointextractor.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:opentrack-prototyping 作者: DaMichel 项目源码 文件源码
def __init__(self, blob_labels, blob_list):
    binary = (blob_labels >= 255).astype(np.uint8)
    dist, labels = cv2.distanceTransformWithLabels(binary, cv2.DIST_L2, 3)
    newlabels = 255*np.ones(blob_labels.shape, np.uint8)
#    plt.imshow(dist)
#    plt.show()
#    plt.imshow(labels)
#    plt.show()
    used_labels = set()
    for i, pk in enumerate(blob_list):
        label = labels[int(pk.x), int(pk.y)]
        #assert(label not in used_labels)
        if label in used_labels:
          raise RuntimeError("Adjacent blobs connected by diagonal. Cannot handle it!")
        used_labels.add(label)
        mask = (labels == label)
        newlabels[mask] = i
    self.labels = newlabels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号