【问题标题】:Partitioning bounding boxes with Union-Find使用 Union-Find 划分边界框
【发布时间】:2023-03-18 10:55:01
【问题描述】:

我想分割一个边界框数组(坐标为[ymin, xmin, ymax, xmax]),正如本文中所述[https://arxiv.org/pdf/1710.06677.pdf][1]。我的阈值将是联合的交集,用于将两个边界框组合在一起。

我了解了 Union-Find 数据结构,并通过一些简单的列表示例对其进行了测试。但是,这些列表只包含整数作为列表元素,而不是边界框,并且我的边界框分区实现不起作用。

我认为问题在于创建集合。因为有了一个简单的列表,我可以将一个整数分配给一个列表索引。但我不能用边界框做到这一点,因此这些例子不适用于我的情况。

有没有人可以帮我实现边界框的 Union-Find 数据结构?

我得到帮助的来源:

https://medium.com/100-days-of-algorithms/day-41-union-find-d0027148376d

https://www.geeksforgeeks.org/union-find/

https://www.cs.cmu.edu/~avrim/451f13/lectures/lect0912.pdf

A set union find algorithm

【问题讨论】:

    标签: python object-detection object-detection-api union-find


    【解决方案1】:

    我设法使它工作。首先,我计算了所有边界框之间的 IOU,并将 > 0.9 的边界框标记为我的图形的边。然而,这个实现得到RecursionError: maximum recursion depth exceeded in comparison 错误与大量边界框。

    我将https://medium.com/100-days-of-algorithms/day-41-union-find-d0027148376d 的实现用于我的代码

    def find(data, i):
       if i != data[i]:
           data[i] = find(data, data[i])
       return data[i]
    
    def union(data, i, j):
       pi, pj = find(data, i), find(data, j)
       if pi != pj:
           data[pi] = pj
    
    connections = []
    for i in range(len(boxes)):
       for j in range(i + 1, len(boxes)):
           iou = compute_iou(boxes[i], boxes[j])
    
           if iou >= 0.9:
              connections.append((i,j))
    
    # data is a representation of the bounding to make it
    # possible to create Union-Find sets   
    data = [bb for bb in range(len(boxes))] 
    
    
    for i, j in connections:
        union(data, i, j)
    

    【讨论】:

      猜你喜欢
      • 2012-06-03
      • 2021-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-20
      • 2015-07-13
      • 1970-01-01
      相关资源
      最近更新 更多