博客
关于我
RT-MDNet代码解读
阅读量:767 次
发布时间:2019-03-24

本文共 1867 字,大约阅读时间需要 6 分钟。

def genConfig(seq_path, set_type):    path, seqname = os.path.split(seq_path)        img_list = sorted([seq_path + '/img/' + p for p in os.listdir(seq_path + '/img') if os.path.splitext(p)[1] == '.jpg'])        if seqname == 'Jogging_1' or seqname == 'Skating2_1':        gt = np.loadtxt(seq_path + '/groundtruth_rect.1.txt')    elif seqname == 'Jogging_2' or seqname == 'Skating2_2':        gt = np.loadtxt(seq_path + '/groundtruth_rect.2.txt')    elif seqname == 'Human4':        gt = np.loadtxt(seq_path + '/groundtruth_rect.2.txt', delimiter=',')    else:        gt = np.loadtxt(seq_path + '/groundtruth_rect.txt', delimiter=',')        if seqname == 'David':        img_list = img_list[299:]    if seqname == 'Football1':        img_list = img_list[0:74]    if seqname == 'Freeman3':        img_list = img_list[0:460]    if seqname == 'Freeman4':        img_list = img_list[0:283]    if seqname == 'Diving':        img_list = img_list[0:215]    if seqname == 'Tiger1':        img_list = img_list[5:]        if gt.shape[1] == 8:        x_min = np.min(gt[:, [0, 2, 4, 6]], axis=1)[:, None]        y_min = np.min(gt[:, [1, 3, 5, 7]], axis=1)[:, None]        x_max = np.max(gt[:, [0, 2, 4, 6]], axis=1)[:, None]        y_max = np.max(gt[:, [1, 3, 5, 7]], axis=1)[:, None]        gt = np.concatenate((x_min, y_min, x_max - x_min, y_max - y_min), axis=1)        return img_list, gt

以下是关于代码的主要描述:

  • 函数定义与参数:

    • 函数genConfig接受两个参数:seq_path(序列路径)和set_type(数据类型)。
  • 图像路径处理:

    • 使用os.path.split(seq_path)分离文件路径和文件名。
    • seq_path + '/img/'中获取所有.jpg图像文件,并按名称排序生成图像列表img_list
  • ground truth数据处理:

    • 根据序列名称seqname选择不同的ground truth文件。
    • 对于特定场景(如Jogging_1Skating2_1等),加载相应的ground truth文件。
  • 图像子集筛选:

    • 针对不同场景调整图像子集范围。
    • 例如David设定从299th图像开始,Football1筛选0-74th图像等。
  • ground truth矩阵转换:

    • 当ground truth的形状为8列时,说明包含4个坐标点和宽高数据。
    • 使用np.concatenate合并最小值和最大值矩阵,构建最终ground truth矩阵。
  • 返回值:

    • 返回处理后的图像列表img_list和ground truth矩阵gt
  • 转载地址:http://cpnkk.baihongyu.com/

    你可能感兴趣的文章
    Python 子进程 Popen 与 Pyinstaller
    查看>>
    Python 子进程 Popen.communicate() 等价于 Popen.stdout.read()?
    查看>>
    Python 子进程 Popen:为什么会出现“ls *.txt“?不行?
    查看>>
    Python 子进程参数
    查看>>
    python 字典 key 和value 互换
    查看>>
    python 字典sorted自定义排序,按照key or value排序
    查看>>
    python 字典和列表区别_元组列表和字典的主要区别是什么?
    查看>>
    python 字符串中特定字符替换,截取
    查看>>
    Python 字符串总结
    查看>>
    python 字符串显示中文_Python字符串开头的b"、u"、r"与中文乱码
    查看>>
    Python 字符串的几种拼装方式
    查看>>
    python 存入数据库bigint_python基础_MySQL的bigint类型
    查看>>
    python 学习 面向对象编程
    查看>>
    Python 学习小结
    查看>>
    Python 学习日记第三篇 -- 字典
    查看>>
    Python 学习笔记(一)Data type
    查看>>
    python 安装 easy_install 和 pip 流程
    查看>>
    python 安装echarts
    查看>>
    python 安装opencv及问题解决
    查看>>
    Python 安装程序:“写入文件 C:\Python27\pythonw.exe 时出错“
    查看>>