visdrone数据集转化为MOT数据集(用作MOTR模型训练)

news2024/10/6 9:11:11

文章目录

  • visdrone数据集转化为MOT数据集
    • MOT17 数据集格式
      • train
        • det.txt
        • gt.txt
        • seqinfo.ini
      • test
        • det.txt
    • visdrone——Task 4_ Multi-Object Tracking
      • 配置seqinfo.ini文件
    • 代码如下
      • Linux

visdrone数据集转化为MOT数据集

MOT17 数据集格式

├── MOT17
│   ├── images
│   ├── labels_with_ids

train

det.txt

10个参数 或者 8个参数

<frame>, <id>, <bb_left>, <bb_top>, <bb_width>, <bb_height>, <conf>, <x>, <y>, <z> 
  • 第1个代表第几帧
  • 第2个代表轨迹编号(在这个文件里总是为-1)
  • bb开头的4个数代表物体框的左上角坐标及长宽
  • conf代表置信度
  • 最后3个是MOT3D用到的内容,2D检测总是为-1.

在这里插入图片描述

gt.txt

9个参数

  • 第1个代表第几帧
  • 第2个值为目标运动轨迹的ID号
  • 第3个到第6个数代表物体框的左上角坐标及长宽
  • 第7个值为目标轨迹是否进入考虑范围内的标志,0表示忽略,1表示active
  • 第8个值为该轨迹对应的目标种类(种类见下面的表格中的label-ID对应情况)
  • 第9个值为box的visibility ratio,表示目标运动时被其他目标box包含/覆盖或者目标之间box边缘裁剪情况。

在这里插入图片描述

seqinfo.ini

主要介绍视频的帧率、分辨率等基本信息。

在这里插入图片描述

test

det.txt

数据标签含义与train相同。

在这里插入图片描述

visdrone——Task 4_ Multi-Object Tracking

    <frame_index>,<target_id>,<bbox_left>,<bbox_top>,<bbox_width>,<bbox_height>,<score>,<object_category>,<truncation>,<occlusion>

 -----------------------------------------------------------------------------------------------------------------------------------
       Name	                                      Description
 -----------------------------------------------------------------------------------------------------------------------------------
   <frame_index>	  The frame index of the video frame
   
    <target_id>	          In the DETECTION result file, the identity of the target should be set to the constant -1.
		          In the GROUNDTRUTH file, the identity of the target is used to provide the temporal corresponding 
		          relation of the bounding boxes in different frames.
			  
    <bbox_left>	          The x coordinate of the top-left corner of the predicted bounding box

    <bbox_top>	          The y coordinate of the top-left corner of the predicted object bounding box

    <bbox_width>	  The width in pixels of the predicted object bounding box

    <bbox_height>	  The height in pixels of the predicted object bounding box

      <score>	          The score in the DETECTION file indicates the confidence of the predicted bounding box enclosing 
                          an object instance.
                          The score in GROUNDTRUTH file is set to 1 or 0. 1 indicates the bounding box is considered in evaluation, 
		          while 0 indicates the bounding box will be ignored.
			  
  <object_category>	  The object category indicates the type of annotated object, (i.e., ignored regions(0), pedestrian(1), 
                          people(2), bicycle(3), car(4), van(5), truck(6), tricycle(7), awning-tricycle(8), bus(9), motor(10), 
                          others(11))
		      
    <truncation>	  The score in the DETECTION file should be set to the constant -1.
                          The score in the GROUNDTRUTH file indicates the degree of object parts appears outside a frame 
		          (i.e., no truncation = 0 (truncation ratio 0%), and partial truncation = 1 (truncation ratio 1% ~ 50%)).
		      
     <occlusion>	  The score in the DETECTION file should be set to the constant -1.
                          The score in the GROUNDTRUTH file indicates the fraction of objects being occluded 
		          (i.e., no occlusion = 0 (occlusion ratio 0%), partial occlusion = 1 (occlusion ratio 1% ~ 50%), 
		          and heavy occlusion = 2 (occlusion ratio 50% ~ 100%)).
├── visdrone
│   ├── images
│   │   ├── train
│   │   │   ├── 视频目录
│   │   │   │   ├── gt
│   │   │   │   ├── img1
│   │   │   │   ├── seqinfo.ini
│   │   ├── test
│   ├── labels_with_ids
│   

配置seqinfo.ini文件

[Sequence]
name=MOT17-02-DPM
imDir=img1
frameRate=30
seqLength=600
imWidth=1920
imHeight=1080
imExt=.jpg

其中,imWidth、imHeight、imExt分别为图片的宽、高、格式;seqLength表示此视频被抽成了多少帧。frameRate为画面更新率。

代码如下

import os
import shutil
from tqdm import tqdm
from PIL import Image


def copyfile(old_folder_path,new_folder_path):
    print('---------------------')
    for file in os.listdir(old_folder_path):
        old_file_path=os.path.join(old_folder_path,file)
        # print(file)
        # print(new_folder_path)
        shutil.copy(old_file_path, new_folder_path)

def makedir(filepath):
    if not os.path.exists(filepath):
        os.mkdir(filepath)

def process(path):
    annotations_path = os.path.join(path, "annotations")
    ann_set = os.listdir(annotations_path)
    # print(ann_set)
    file_path=os.path.join(path,'sequences')
    file_set=os.listdir(file_path)
    # print(file_set)
    for i in tqdm(ann_set):
        f = open(annotations_path + "/" + i, "r")
        print(i)
        name = i.replace(".txt", "")
        print(name)
        img_path=os.path.join(file_path,name)
        img_set=os.listdir(img_path)
        img=Image.open(os.path.join(img_path,img_set[0]))
        for line in f.readlines():
            line = line.replace("\n", "")
            if line.endswith(","):  # filter data
                line = line.rstrip(",")
            line_list = [int(i) for i in line.split(",")]
            new_line_list=[line_list[i] for i in range(0,8)]
            print(line_list)
            # print(new_line_list)
            if(line_list[8]==0 and line_list[9]==0):
                new_line_list.append(1)
            if (line_list[8] == 0 and line_list[9] == 1):
                new_line_list.append(0.9)
            if (line_list[8] == 1 and line_list[9] == 0):
                new_line_list.append(0.8)
            if (line_list[8] == 0 and line_list[9] == 2):
                new_line_list.append(0.7)
            if (line_list[8] == 1 and line_list[9] == 1):
                new_line_list.append(0.5)
            if (line_list[8] == 1 and line_list[9] == 2):
                new_line_list.append(0.3)
            # print(new_line_list)
            url1 = os.path.join(path,name)
            makedir(url1)
            url2=os.path.join(name,'gt')
            makedir(url2)
            file_url=url2+'\\gt.txt'
            print(url2)
            print(file_url)
            if not os.path.isfile(file_url):
                fd = open(file_url, mode="w", encoding="utf-8")
            makedir(file_url)
            with open(file_url, 'a') as file_name:
                str_text = str(new_line_list[0]) + ',' + str(new_line_list[1]) + ',' + str(new_line_list[2]) + ',' + str(
                    new_line_list[3]) + ',' + str(new_line_list[4]) + ',' + str(new_line_list[5]) + ',' + str(
                    new_line_list[6]) + ',' + str(new_line_list[7])+ ',' + str(new_line_list[8])
                print(str_text)
                file_name.write(str_text + '\n')

        ini_path = os.path.join(path, name)
        ini_file=ini_path+'\\seqinfo.ini'
        print('***********************************')
        if not os.path.isfile(ini_file):
            fd = open(ini_file, mode="w", encoding="utf-8")
        with open(ini_file, 'a') as ini_name:
            ini_text ='[Sequence]\n'+'name='+name+'\n'+'imDir=img1\n'+'frameRate=30\n'+'seqLength='+str(len(img_set))+'\n'+'imWidth = '+str(img.size[0])+'\n'+'imHeight = '+str(img.size[1])+'\n'+'imExt =.jpg\n'
            print(ini_text)
            ini_name.write(ini_text + '\n')
        break
    old_path=os.path.join(file_path,name)
    new_path=os.path.join(path,name,'img1')
    print(old_path)
    print(new_path)
    move(old_path,new_path)

def move(old_path,new_path):
    makedir(new_path)
    copyfile(old_path,new_path)

if __name__ == '__main__':
    path1=r'D:\pythonProjects\Test\visdrone2mot\annotations'
    path2=r'D:\pythonProjects\Test\visdrone2mot\sequences'
    path=r'D:\pythonProjects\Test\visdrone2mot'
    process(path)

Linux

import os
import shutil
from tqdm import tqdm
from PIL import Image


def copyfile(old_folder_path,new_folder_path):
    print('---------------------')
    for file in os.listdir(old_folder_path):
        old_file_path=os.path.join(old_folder_path,file)
        # print(file)
        # print(new_folder_path)
        shutil.copy(old_file_path, new_folder_path)

def makedir(filepath):
    if not os.path.exists(filepath):
        os.mkdir(filepath)

def process(path):
    annotations_path = os.path.join(path, "annotations")
    ann_set = os.listdir(annotations_path)
    # print(ann_set)
    file_path=os.path.join(path,'sequences')
    file_set=os.listdir(file_path)
    # print(file_set)
    for i in tqdm(ann_set):
        f = open(annotations_path + "/" + i, "r")
        print(i)
        name = i.replace(".txt", "")
        print(name)
        img_path=os.path.join(file_path,name)
        img_set=os.listdir(img_path)
        img=Image.open(os.path.join(img_path,img_set[0]))
        old_path = os.path.join(file_path, name)
        new_path = os.path.join(path, name, 'img1')
        print(old_path)
        print(new_path)
        move(old_path, new_path)
        for line in f.readlines():
            line = line.replace("\n", "")
            if line.endswith(","):  # filter data
                line = line.rstrip(",")
            line_list = [int(i) for i in line.split(",")]
            new_line_list=[line_list[i] for i in range(0,8)]
            print(line_list)
            # print(new_line_list)
            if(line_list[8]==0 and line_list[9]==0):
                new_line_list.append(1)
            if (line_list[8] == 0 and line_list[9] == 1):
                new_line_list.append(0.9)
            if (line_list[8] == 1 and line_list[9] == 0):
                new_line_list.append(0.8)
            if (line_list[8] == 0 and line_list[9] == 2):
                new_line_list.append(0.7)
            if (line_list[8] == 1 and line_list[9] == 1):
                new_line_list.append(0.5)
            if (line_list[8] == 1 and line_list[9] == 2):
                new_line_list.append(0.3)
            # print(new_line_list)
            url1 = os.path.join(path,name)
            makedir(url1)
            print('url1:',url1)
            url2=os.path.join(url1,'gt')
            print('url2:',url2)
            makedir(url2)
            file_url=url2+'/gt.txt'
            print(url2)
            print(file_url)
            if not os.path.isfile(file_url):
                fd = open(file_url, mode="w", encoding="utf-8")
            makedir(file_url)
            with open(file_url, 'a') as file_name:
                str_text = str(new_line_list[0]) + ',' + str(new_line_list[1]) + ',' + str(new_line_list[2]) + ',' + str(
                    new_line_list[3]) + ',' + str(new_line_list[4]) + ',' + str(new_line_list[5]) + ',' + str(
                    new_line_list[6]) + ',' + str(new_line_list[7])+ ',' + str(new_line_list[8])
                print(str_text)
                file_name.write(str_text + '\n')

        ini_path = os.path.join(path, name)
        ini_file=ini_path+'/seqinfo.ini'
        print('***********************************')
        if not os.path.isfile(ini_file):
            fd = open(ini_file, mode="w", encoding="utf-8")
        with open(ini_file, 'a') as ini_name:
            ini_text ='[Sequence]\n'+'name='+name+'\n'+'imDir=img1\n'+'frameRate=30\n'+'seqLength='+str(len(img_set))+'\n'+'imWidth = '+str(img.size[0])+'\n'+'imHeight = '+str(img.size[1])+'\n'+'imExt =.jpg\n'
            print(ini_text)
            ini_name.write(ini_text + '\n')
        # break
      

def move(old_path,new_path):
    makedir(new_path)
    copyfile(old_path,new_path)

if __name__ == '__main__':
    path='/home/course/ldw/dataset/VisDrone2019-MOT-val/'
    process(path)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/134193.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

YOLO学习记录之模型修改

我们在做实验时&#xff0c;不免需要对模型结构进行修改来检测自己的改进性能&#xff0c;对于一般模型而言&#xff0c;我们只需要简单的在代码中添加网络层即可&#xff0c;但对于一些预训练好的模型&#xff0c;我们则需要进行较为复杂的修改。以我们的YOLOV7模型为例&#…

[Linux]----守护进程

文章目录前言一、什么是守护进程?二、会话和进程组会话进程组三、守护进程的编程流程总结前言 这节课我来给大家讲解在Linux下如何让进程守护化,运行在后台,处理我们的任务. 正文开始! 一、什么是守护进程? 守护进程也称为精灵进程(Daemon),是运行在后台的一种特殊进程.它…

Mybatis-Plus快速使用相关知识点1

Mybatis-Plus的mapper、service 基本CURD BaseMapper BaseMapper是MyBatis-Plus提供的模板mapper&#xff0c;其中包含了基本的CRUD方法&#xff0c;泛型为操作的实体类型&#xff0c;Mapper 继承该接口后&#xff0c;无需编写 mapper.xml 文件&#xff0c;即可获得CRUD功能…

JavaScript刷LeetCode拿offer-链表篇

一、链表 链表&#xff08;Linked List&#xff09;是一种常见的基础数据结构&#xff0c;也是线性表的一种。 一个线性表是 n 个具有相同特性的数据元素的有限序列&#xff0c;线性表的存储结构分为两类&#xff1a;顺序表&#xff08;数组&#xff09;和链表。 链表相比较顺…

站得高,望得远

1、站得高&#xff0c;望的远 计算机科学领域的任何问题都可以通过增加一个间接的中间层来解决。 这句话几乎概括了计算机系统软件体系结构的设计要点 &#xff0c;整个体系结构从上到下都是按照严格的层次结构设计的。不仅是计算机系统软件整个体系是这样的&#xff0c;体系里…

884. 两句话中的不常见单词 map与stringstream

目录 力扣884. 两句话中的不常见单词 【解法一】&#xff1a;最后写出了一坨屎&#xff0c;虽然它是一坨屎&#xff0c;但是它能动&#xff0c;虽然它是一坨屎&#xff0c;但起码这是我自己拉的 【大佬解法】 stringstream的使用 以及 map的使用 884. 两句话中的不常见单词 句…

python实现bib文件中参考文献的题目每个单词首字母大写

文章目录前言实现思路前言 由于毕业论文格式要求英文参考文献的题目的每个单词&#xff08;除了介词&#xff09;的首字母都要大写&#xff0c;如果一条条地自己修改费时费力&#xff0c;这里就想着简单地用python操作字符串的方式实现。 实现思路 观察bib参考文献格式&#x…

20230102单独编译Toybrick的TB-RK3588X开发板的Android12的内核

20230102单独编译Toybrick的TB-RK3588X开发板的Android12的内核 2023/1/2 17:40 《RK3588_Android12_SDK_Developer_Guide_CN.pdf》 原厂的开发板rk3588-evb1-lp4-v10单独编译内核的方式&#xff1a; cd kernel-5.10 export PATH../prebuilts/clang/host/linux-x86/clang-r4161…

【数据结构】C语言实现链表(单链表部分)

目录 前言 链表 链表的分类 1.单向或者双向 2.带头或者不带头 3.循环或者非循环 单链表实现 定义节点 接口函数实现 创建节点 打印链表 尾插节点 尾删节点 头插节点 头删节点 单链表查找 删除指定位置后的节点 指定位置后插入节点 删除指定位置 指定位置插入节点…

Linux-7 文本编辑vivim

Linux-7 文本编辑vi/vim vim介绍 什么是vim&#xff1f; vi和vim是Linux下的一个文本编辑工具。&#xff08;可以李姐为Windows的记事本或word文档&#xff09; 为什么要使用vim&#xff1f; 因为Linux系统一切皆为文件&#xff0c;而我们工作最多的就是修改某个服务的配置&a…

一名七年老安卓的 2022 总结

大家好&#xff0c;我是 shixin。一转眼到了 2022 的最后一天&#xff0c;今年发生了很多事&#xff0c;这篇文章来总结一下。长短期目标达成情况和去年一样&#xff0c;我的长期目标是成为具备创业能力的人&#xff0c;包括商业思维和全栈技术能力。总的来说&#xff0c;今年是…

STM32MP157驱动开发——USB设备驱动

STM32MP157驱动开发——USB设备驱动一、简介1.电气属性2.USB OTG3.STM32MP1 USB 接口简介4.Type-C 电气属性二、USB HOST 驱动开发1.USB HOST 驱动编写2.配置 PHY 控制器3.配置usbh_ehci三、USB HOST 测试1.鼠标键盘驱动使能2.U盘驱动四、USB OTG驱动开发1.USB OTG 控制器节点信…

系统设计实战一

文章目录前言一、服务幂等1.防止订单重复下单1.1 场景如下&#xff1a;当用户在提交订单的时候1.2 重复下单解决方案1.3案例一幂等性总结2 防止订单ABA问题2.1 场景如下&#xff1a;当在修改订单用户信息的时候发生服务器或者网络问题导致的重试2.2 ABA问题解决方案2.3 业务ABA…

Mac本地安装Mysql并配置

文章目录一、安装Mysql二、配置Mysql三、启动mysql四、SQL语法初步了解1.创建数据库2.建表3.查看表一、安装Mysql 笔者推荐采用安装包的方法安装Mysql&#xff0c;比较简单&#xff0c;适合新手。 首先在网上搜安装包&#xff1a; baidu按关键字搜即可&#xff1a;mysql mac安…

多兴趣向量重构用户向量

Re4: Learning to Re-contrast, Re-attend, Re-construct for Multi-interest Recommendation 论文地址&#xff1a;https://arxiv.org/pdf/2208.08011.pdf 一般的多兴趣建模过程是对用户序列进行编码&#xff0c;抽取出用户的多个兴趣向量&#xff0c;然后利用这些用户兴趣向…

【Vue中使用Echarts】echarts初体验

文章目录一、echarts简介二、初次体验echarts1.下载2.在vue中引入echarts①全局引入&#xff08;代码&#xff09;② 局部引入一、echarts简介 在大数据盛行的今天&#xff0c;数据可视化变得越来越广泛。而在前端工作中&#xff0c;数据可视化用得最多的&#xff0c;可能就是…

Usaco Training 刷怪旅 第三层 第四题 :Combination Lock

一个六年级博主写文章不容易&#xff0c;给个关注呗 &#xff08;点赞也行啊&#xff09; 本蒟蒻的bilibili账号 注&#xff1a;这种题当你看不懂的时候是可以把题目复制去洛谷看中文版的 Farmer Johns cows keep escaping from his farm and causing mischief. To try and pre…

如何通过 Python 与 ChatGPT 对话

文章目录简介安装 OpenAI API实例1预备条件: 1. 科学上网&#xff1b; 2. 注册 OpenAI 账号。 简介 ChatGPT 是 GPT-3 语言模型的变体&#xff0c;专为会话语言生成而设计。要在 Python 中使用 ChatGPT&#xff0c;您需要安装 OpenAI API 客户端并获取 API 密钥。当前提你需要…

前端工程师leetcode算法面试必备-二分搜索算法(中)

一、前言 二分搜索算法本身并不是特别复杂&#xff0c;核心点主要集中在&#xff1a; 有序数组&#xff1a;指的是一个递增或者递减的区间&#xff08;特殊情况如&#xff1a;【852. 山脉数组的峰顶索引】&#xff09;&#xff1b; 中间数&#xff1a;用来确定搜索目标落在左…

Pytorch学习笔记①——anaconda和jupyter环境的安装(小白教程)

一、安装Pytorch 1、首先找到anaconda命令端并点击进入。 2、输入如下命令创建子空间&#xff08;博主的命名是pytorch1.4.0&#xff0c;使用python3.6版本&#xff09; conda create -n pytorch1.4.0 python3.6对于下载速度慢的话&#xff0c;首先需要进行换源&#xff0c;换…