首页 > 其他分享 >什么是多目标跟踪中的Interpolation / OC-SORT

什么是多目标跟踪中的Interpolation / OC-SORT

时间:2022-08-23 11:56:35浏览次数:85  
标签:SORT seq frame OC results left data id Interpolation

什么是多目标跟踪中的Interpolation

解释

如果每个track_id属于多个Tracklet/segment,并且段[i]和段[i+1]在小于N_ DTI的间隔内,段[i]和段[i+1]之间的帧(未分配给该track_id)将被分配。

这属于一种后处理手段,作用是连接局部中断,但是具有相同track_id的跟踪片段

代码

核心:跟踪框插值

curr_bbox = (curr_frame - left_frame_id) * (right_bbox - left_bbox)/(right_frame_id - left_frame_id) + left_bbox

https://github.com/noahcao/OC_SORT/blob/43d2f29d3df8ecccf1dfaa2e466c6911f5c74b27/tools/interpolation.py

import numpy as np
from tqdm import tqdm
import os
import glob
import sys 

""" 
Linear Interpolation
for each track_id, if it belongs to multiple tracklets/segments,
if segments[i] and segments[i+1] are within an interval less than N_DTI, 
then 
"""

def write_results_score(filename, results):
    save_format = '{frame}, {id}, {x1}, {y1}, {w}, {h}, {s}, -1, -1, -1\n'
    with open(filename, 'w') as f:
        for i in range(results.shape[0]):
            frame_data = results[i]
            frame_id = int(frame_data[0])
            track_id = int(frame_data[1])
            x1, y1, w, h = frame_data[2:6]
            score = frame_data[6]
            line = save_format.format(frame=frame_id, id=track_id, x1=x1, y1=y1, w=w, h=h, s=-1)
            f.write(line)


def dti(txt_path, save_path, n_min=25, n_dti=20):
    seq_txts = sorted(glob.glob(os.path.join(txt_path, '*.txt')))
    for seq_txt in tqdm(seq_txts):
        seq_name = seq_txt.split('/')[-1]
        seq_data = np.loadtxt(seq_txt, dtype=np.float64, delimiter=',')
        min_track_id = int(np.min(seq_data[:, 1]))
        max_track_id = int(np.max(seq_data[:, 1]))
        seq_results = np.zeros((1, 10), dtype=np.float64)
        for track_id in range(min_track_id, max_track_id + 1):
            index = (seq_data[:, 1] == track_id)
            tracklet = seq_data[index]
            tracklet_dti = tracklet
            if tracklet.shape[0] == 0:
                continue
            n_frame = tracklet.shape[0]
            n_conf = np.sum(tracklet[:, 6] > 0.5)
            if n_frame > n_min:
                frame_idxs = tracklet[:, 0]
                frames_interpolated = {}
                for i in range(0, n_frame):
                    right_frame_id = frame_idxs[i]
                    if i > 0:
                        left_frame_id = frame_idxs[i - 1]
                    else:
                        left_frame_id = frame_idxs[i]
                    interval = right_frame_id-left_frame_id
                    if interval>1:
                        print(interval)
                    # disconnected track interpolation
                    if 1 < right_frame_id - left_frame_id < n_dti:
                        num_bi = int(right_frame_id - left_frame_id - 1)
                        right_bbox = tracklet[i, 2:6]
                        left_bbox = tracklet[i - 1, 2:6]
                        for j in range(1, num_bi + 1):
                            curr_frame = j + left_frame_id
                            curr_bbox = (curr_frame - left_frame_id) * (right_bbox - left_bbox) / \
                                        (right_frame_id - left_frame_id) + left_bbox
                            frames_interpolated[curr_frame] = curr_bbox
                num_itpl = len(frames_interpolated.keys())
                if num_itpl > 0:
                    data_dti = np.zeros((num_itpl, 10), dtype=np.float64)
                    # for each interpolated frame
                    for n in range(num_itpl):
                        data_dti[n, 0] = list(frames_interpolated.keys())[n]
                        data_dti[n, 1] = track_id
                        data_dti[n, 2:6] = frames_interpolated[list(frames_interpolated.keys())[n]]
                        data_dti[n, 6:] = [1, -1, -1, -1]
                    tracklet_dti = np.vstack((tracklet, data_dti))
            seq_results = np.vstack((seq_results, tracklet_dti))
        save_seq_txt = os.path.join(save_path, seq_name)
        seq_results = seq_results[1:]
        # seq_results = seq_results[seq_results[:, 0].argsort()]
        seq_results = seq_results[np.lexsort((seq_results[:,0],seq_results[:,1]))]
        write_results_score(save_seq_txt, seq_results)



if __name__ == '__main__':
    # txt_path, save_path = sys.argv[1], sys.argv[2]
    NAME = 'ocsort_640_960'
    txt_path =  f'XXX/{NAME}/data'
    save_path = f'XXX/{NAME}/interpolated'
    os.makedirs(save_path,exist_ok=True)
    dti(txt_path, save_path, n_min=30, n_dti=20)

标签:SORT,seq,frame,OC,results,left,data,id,Interpolation
From: https://www.cnblogs.com/zxyfrank/p/16615634.html

相关文章

  • Got permission denied while trying to connect to the Docker daemon socket at uni
    [问题解决]GotpermissiondeniedwhiletryingtoconnecttotheDockerdaemonsocketatunix:///var/run/docker.sock 写了一个脚本读取docker日志,发生报错:Gotp......
  • 数组排序方法sort---案例
    <template><divclass="Leading"><h2>人员列表</h2><inputtype="text"placeholder="请输入名字"v-model="keyword"><br><!--{{keyword}}-->......
  • 谈谈你对IOC的理解
    IoC(InverseofControl:控制反转)是一种设计思想,而不是一个具体的技术实现。为spring两大核心思想之一,IoC的思想就是将原本在程序中手动创建对象的控制权,交由Spring框架......
  • package.json 与 package-lock.json 的关系
    模块化开发在前端越来越流行,使用node和npm可以很方便的下载管理项目所需的依赖模块。package.json用来描述项目及项目所依赖的模块信息。那 package-lock.json 和......
  • centos8 安装docker、docker-compose、kvm
    目录安装docker-ce安装docker-compose安装kvm安装docker-cecd/etc/yum.repos.d/rm-rf./*yumremovepodman-manpages.noarch-ywget-O/etc/yum.repos.d/CentOS-B......
  • Jenkins+Docker 一键自动化部署 SpringBoot 项目
    实现最简单全面的Jenkins+docker+springboot 一键自动部署项目,步骤齐全,少走坑路。环境:centos7+git(gitee)简述实现步骤:在docker安装jenkins,配置jenkins基本信息,利用Do......
  • Docker 拉取Nginx镜像 和运行
    Docker镜像拉取dockerpull[OPTIONS]NAME[:TAG|@DIGEST]镜像拉取命令OPTIONS说明:-a:拉取所有tagged镜像--disable-conten......
  • Docker 容器的 health 健康状态检查
    Docker原生健康检查能力自1.12版本之后,Docker引入了原生的健康检查实现。对于容器而言,最简单的健康检查是进程级的健康检查,即检验进程是否存活。DockerDaemon会自动......
  • 年轻的樵夫哟,你掉的是这个免费 8 核 4G 公网Docker 服务器
    PlayWithDocker直接打开 https://labs.ply-with-docker.com/ 即可访问PlayWithDocker平台。注册一个DockerHub账号便可以访问这个站点,轻松地获得一台8核4G......
  • IDEA Version Control 窗口 local changes显示
    IDEA2022以前窗口底部是有个VersionControl的窗口的(如下图所示),但是现在没有了  可以进入Settings/Preferences/VersionControl/Commit将Usenon-modalcommitinter......