【问题标题】:Convert Kitti Labels To yolo format将 Kitti 标签转换为 yolo 格式
【发布时间】:2022-06-23 16:22:30
【问题描述】:

尝试将 Kitti 标签格式转换为 Yolo。但是转换后的 bbox 放错了位置。这是kitti边界框。

这是转换代码:

def convertToYoloBBox(bbox, size):
# Yolo uses bounding bbox coordinates and size relative to the image size.
# This is taken from https://pjreddie.com/media/files/voc_label.py .
dw = 1. / size[0]
dh = 1. / size[1]
x = (bbox[0] + bbox[1]) / 2.0
y = (bbox[2] + bbox[3]) / 2.0
w = bbox[1] - bbox[0]
h = bbox[3] - bbox[2]
x = x * dw
w = w * dw
y = y * dh
h = h * dh
return (x, y, w, h)


convert =convertToYoloBBox([kitti_bbox[0],kitti_bbox[1],kitti_bbox[2],kitti_bbox[3]],image.shape[:2])

该函数进行了一些对 yolo 至关重要的归一化,并输出以下内容:

(0.14763590391908976, 0.3397063758389261, 0.20452591656131477, 0.01810402684563757)

但是当我尝试使用此代码检查规范化是否正确完成时:

x = int(convert[0] * image.shape[0])
y = int(convert[1] * image.shape[1])  
width = x+int(convert[2] * image.shape[0]) 
height = y+ int(convert[3] * image.shape[1])

cv.rectangle(image, (int(x), int(y)), (int(width), int(height)), (255,0,0), 2 )

边界框放错了

有什么建议吗?转换功能是否正确?还是问题出在检查代码中?

【问题讨论】:

    标签: python machine-learning object-detection yolov5


    【解决方案1】:

    你有没有得到任何答案,如果有,请更新?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-13
    • 2021-09-11
    • 2021-01-22
    • 2015-11-20
    • 1970-01-01
    • 2022-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多