如何解决如何对YOLOv4边界框进行排序?
我已经训练了来自 alexeyab darknet repo 的 yolov4 来检测车牌中的字符。它正确地分割了字符,但边界框的顺序是随机的。对于这样的图像,我如何从左上角到右下角对边界框进行排序:(这不是实际使用的图像,但由于机密数据,这是尼泊尔车牌示例的 photoshoped 图像)
我试过了:(来自pyimagesearch)
def sort_bbox(bbox,method="left-to-right"):
# initialize the reverse flag and sort index
reverse = False
i = 0
# handle if we need to sort in reverse
if method == "right-to-left" or method == "bottom-to-top":
reverse = True
# handle if we are sorting against the y-coordinate rather than
# the x-coordinate of the bounding box
if method == "top-to-bottom" or method == "bottom-to-top":
i = 1
# construct the list of bounding boxes and sort them from top to
# bottom
boundingBoxes = sorted(bbox,key=lambda b: b[1],reverse=reverse)
# return the list of sorted contours and bounding boxes
return boundingBoxes
但没有对边界框进行排序。它仍然是随机顺序。
我有这样的 yolov4 检测边界框:xywh 中的未排序边界框:[[50,12,15,18],[66,10,19],[87,19,20],[21,24,[51,17],[86,11,[39,32,27,29],[68,33,28,27],[97,31,30],[12,37,25],[11,35,25,[40,34,28],28]]
和上面的排序代码:[[66,[50,25]]
我想要的是边界框:बा २ प ८ ८ ८ ८
非常感谢任何帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。