如何从右到左、从上到下排列对象检测边界框列表?
我正在尝试从右到左、从上到下对对象检测后获得的边界框列表进行排序。 下面是边界框位置,
bbox = [(637, 207, 681, 207), (679, 99, 726, 99), (747, 497, 798, 497), (829, 124, 892, 124), (1002, 131, 1059, 131), (1010, 656, 1071, 656)]
我根据 xmin 值对此列表进行排序,如下图
sorted(bbox,key=lambda x:x[2][0])
所示,我最终得到了边界框排列,如下图所示 [![示例图片][1]][1]
序列不按顺序排列,序列应从左到右、从上到下开始,如下图所示 [![sample2][2]][2]
任何实现这一目标的建议或指南将受到高度赞赏
I'm trying to sort the list of bounding boxes obtained after object detection from right to left and top to down.
Below are the bounding box locations
bbox = [(637, 207, 681, 207), (679, 99, 726, 99), (747, 497, 798, 497), (829, 124, 892, 124), (1002, 131, 1059, 131), (1010, 656, 1071, 656)]
I sorted this list based on xmin value as below
sorted(bbox,key=lambda x:x[2][0])
I ended up getting bounding box arrangement as shown in the below image
[![sample image][1]][1]
the sequence is not in order , the sequence should start from left to right and top to bottom as shown in below image
[![sample2][2]][2]
any suggestion or guide to achieve this will be highly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要按最接近左上角的点排序吗?
如果是这样,您需要计算距该角的距离,然后排序:
这将打印出点的顺序。
我假设每个点的前 2 个坐标是 x 和 y,原点位于左上角。
You want the points sorted by closest to the upper-left corner?
If so you need to calculate the distance from that corner and only then sort:
This will print out the order of the points.
I assumed the first 2 coordinates in each point are the x and y and that the origin is in the upper-left corner.