前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【目标跟踪】MOT数据集GroundTruth可视化

【目标跟踪】MOT数据集GroundTruth可视化

作者头像
zstar
发布2023-07-11 14:03:44
4570
发布2023-07-11 14:03:44
举报
文章被收录于专栏:往期博文往期博文

MOT数据集格式简介

MOT15数据集下载:https://pan.baidu.com/s/1foGrBXvsanW8BI4eybqfWg?pwd=8888

以下为一行gt示例:

1,1,1367,393,73,225,1,-1,-1,-1

各列数据对应含义如下

代码语言:javascript
复制
<frame>,<id>,<bb_left>,<bb_top>,<bb_width>,<bb_height>,<conf>,<x>,<y>,<z>
  • frame:图片帧id
  • id:目标id
  • bb_left:bbox左上角坐标x
  • bb_top:bbox左上角坐标y
  • bb_width:bbox的宽度
  • bb_height:bbox的高度
  • conf:置信度
  • x:三维坐标系x值,对于二维任务填充为-1
  • y:三维坐标系y值,对于二维任务填充为-1
  • z:三维坐标系z值,对于二维任务填充为-1

gt可视化

由于是跟踪任务,因此在可视化检测框的同时进一步添加箭头,用来标识目标的运动轨迹。

处理思路是读取一张图片后,同时读取两张图片的gt,若两张图片同时包含同一个目标,则用箭头连接前一帧bbox的中心点和后一帧bbox的中心点。

具体代码如下:

代码语言:javascript
复制
import cv2


def match_obj(obj_list, obj_id):
    try:
        index = obj_list.index(obj_id)
    except:
        index = -1
    return index


def main(i):
    img = cv2.imread("img/" + "0000{:0>2d}.jpg".format(i))
    img2 = img
    with open('gt/gt.txt', 'r') as f:
        lines = f.readlines()
        object_list = []
        center_list = []
        for line in lines:
            img_id = line.split(',')[0]
            if img_id == str(i):
                object_id = line.split(',')[1]
                object_list.append(object_id)
                x, y, w, h = int(line.split(',')[2]), int(line.split(',')[3]), int(line.split(',')[4]), int(
                    line.split(',')[5])
                center1 = (int(int(x) + int(w) / 2), int(int(y) + int(h) / 2))
                center_list.append(center1)
            if img_id == str(int(i) + 1):
                object_id = line.split(',')[1]
                index = match_obj(object_list, object_id)
                x, y, w, h = int(line.split(',')[2]), int(line.split(',')[3]), int(line.split(',')[4]), int(
                    line.split(',')[5])
                center2 = (int(int(x) + int(w) / 2), int(int(y) + int(h) / 2))
                if index != -1:
                    img2 = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255))
                    img2 = cv2.arrowedLine(img2, center_list[index], center2, (0, 255, 255), 1, 8, 0, 0.5)

    cv2.imwrite("result/" + "0000{:0>2d}.jpg".format(i), img2)


if __name__ == '__main__':
    for i in range(1, 52):
        main(i)

可视化效果如图所示:

在这里插入图片描述
在这里插入图片描述
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2023-06-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • MOT数据集格式简介
  • gt可视化
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档