目标跟踪——deepsort算法详细阐述

deepsort 算法详解
Unmatched Tracks(未匹配的轨迹)

本质角色:已存在的轨迹在当前帧中“失联”的状态,即预测位置与检测结果不匹配。
生命周期阶段:
已初始化: 轨迹已存在多帧,可能携带历史信息(如外观特征、运动模型)。
未被观测到: 当前帧中未找到对应的检测框,可能因
遮挡、目标消失或检测漏检
导致。
处理逻辑:
未匹配计数增加: 记录连续未匹配的帧数(如time_since_update)。
删除条件: 若未匹配次数超过阈值(如max_age),轨迹被删除。
预测继续: 即使未匹配,算法仍会预测下一帧的位置,以尝试重新匹配。

Unmatched Detections(未匹配的检测框)

本质角色: 是新检测到的候选目标,未被任何现有轨迹“认领”。

生命周期阶段:

  • 新出现的候选: 当前帧的检测结果,尚未被关联到已有轨迹。
  • 可能初始化为新轨迹:若未匹配到任何轨迹,需决定是否将其作为新轨迹的起点。

处理逻辑:

  • 初始化为新轨迹:
    • SORT:直接初始化为新轨迹(无确认机制)。
    • DeepSORT:需满足连续匹配次数阈值(如n_init=3)才能转为“确认态”。
  • 外观特征记录:DeepSORT会保存检测框的外观特征(如深度学习提取的向量),用于后续匹配。
维度Unmatched TracksUnmatched Detections
本质历史存在但暂时未被观测到的目标新出现但未被关联到任何目标的候选
处理逻辑删除或保留决策初始化新轨迹或忽略
算法目标保持轨迹连续性与鲁棒性发现新目标与抗干扰
2. 卡尔曼滤波代码分析
2. 1 初始化状态转移矩阵 F F F和观测矩阵 H H H
class KalmanFilterXYAH:"""A KalmanFilterXYAH class for tracking bounding boxes in image space using a Kalman filter.Implements a simple Kalman filter for tracking bounding boxes in image space. The 8-dimensional state space(x, y, a, h, vx, vy, va, vh) contains the bounding box center position (x, y), aspect ratio a, height h, and theirrespective velocities. Object motion follows a constant velocity model, and bounding box location (x, y, a, h) istaken as a direct observation of the state space (linear observation model).Attributes:_motion_mat (np.ndarray): The motion matrix for the Kalman filter.    F_update_mat (np.ndarray): The update matrix for the Kalman filter.    H_std_weight_position (float): Standard deviation weight for position.  标准差的权重[x  y  a  h  dx dy da dh ]_std_weight_velocity (float): Standard deviation weight for velocity.Methods:initiate: Creates a track from an unassociated measurement.predict: Runs the Kalman filter prediction step.project: Projects the state distribution to measurement space.multi_predict: Runs the Kalman filter prediction step (vectorized version).update: Runs the Kalman filter correction step.gating_distance: Computes the gating distance between state distribution and measurements.Examples:Initialize the Kalman filter and create a track from a measurement>>> kf = KalmanFilterXYAH()>>> measurement = np.array([100, 200, 1.5, 50])>>> mean, covariance = kf.initiate(measurement)>>> print(mean)>>> print(covariance)"""def __init__(self):"""Initialize Kalman filter model matrices with motion and observation uncertainty weights.The Kalman filter is initialized with an 8-dimensional state space (x, y, a, h, vx, vy, va, vh), where (x, y)represents the bounding box center position, 'a' is the aspect ratio, 'h' is the height, and their respectivevelocities are (vx, vy, va, vh). The filter uses a constant velocity model for object motion and a linearobservation model for bounding box location.Examples:Initialize a Kalman filter for tracking:>>> kf = KalmanFilterXYAH()"""ndim, dt = 4, 1.0# Create Kalman filter model matricesself._motion_mat = np.eye(2 * ndim, 2 * ndim)   # F[8,8]for i in range(ndim):self._motion_mat[i, ndim + i] = dtself._update_mat = np.eye(ndim, 2 * ndim)       # H[4,8]# Motion and observation uncertainty are chosen relative to the current state estimate. These weights control# the amount of uncertainty in the model.self._std_weight_position = 1.0 / 20self._std_weight_velocity = 1.0 / 160
  • ndim = 4:表示位置相关状态的数量,即 x , y , a , h x, y, a, h x,y,a,h(中心坐标、宽高比、高度)。
  • dt = 1.0:时间步长,默认为1秒。
  • 状态转移矩阵 F F F_motion_mat
  • 观测矩阵 H H H_update_mat),4×8的单位矩阵,仅保留前4行(对应位置和尺寸 x x x, y y y, a a a, h h h
  • std_weight_position:位置噪声权重(默认 0.05)。
  • std_weight_velocity:速度噪声权重(默认 0.00625)
2.2 initiate 方法分析

initiate 方法用于根据初始观测值(未关联的检测框)创建一个新的跟踪轨迹的初始状态(均值向量和协方差矩阵)
输入: 观测值为 z 0 = [ x , y , a , h ] z_0 = [x, y, a, h] z0=[x,y,a,h]
输出:

  • 均值向量 μ 0 \mu_0 μ0: 8维(包含位置和速度的初始估计)
  • 协方差矩阵 P 0 P_0 P0 :8×8维,表示初始状态的不确定性均值向量。
   def initiate(self, measurement: np.ndarray) -> tuple:"""Create a track from an unassociated measurement.Args:measurement (ndarray): Bounding box coordinates (x, y, a, h) with center position (x, y), aspect ratio a,and height h.Returns:(tuple[ndarray, ndarray]): Returns the mean vector (8-dimensional) and covariance matrix (8x8 dimensional)of the new track. Unobserved velocities are initialized to 0 mean.Examples:>>> kf = KalmanFilterXYAH()>>> measurement = np.array([100, 50, 1.5, 200])>>> mean, covariance = kf.initiate(measurement)   # x_k,  p_k"""mean_pos = measurement               # [4,] [x, y, a, h]mean_vel = np.zeros_like(mean_pos)   # [4,] [0, 0, 0, 0]mean = np.r_[mean_pos, mean_vel]     # [8,]  np.r_[] 按行放在一起    [100,50,1.5,200,0,0,0,0]std = [2 * self._std_weight_position * measurement[3], 	# x 方向2 * self._std_weight_position * measurement[3], 	# y 方向1e-2,												# a 2 * self._std_weight_position * measurement[3], 	# h方向 10 * self._std_weight_velocity * measurement[3],	# v_x10 * self._std_weight_velocity * measurement[3],	# v_y1e-5,												# v_a10 * self._std_weight_velocity * measurement[3],	# v_h]   # [20.0, 20.0, 0.01, 20.0, 12.5, 12.5, 1e-05, 12.5]covariance = np.diag(np.square(std))    # [8,8] 对角矩阵  [20^2, 20^2 , 0.01^2, 20^2, 12.5^2, 12.5^2, (1e−5)^2, 12.5^2]return mean, covariance                 # (8,), (8, 8) 
2.3 predict方法分析

predict方法实现了卡尔曼滤波的预测步骤,通过状态转移矩阵 F \mathbf{F} F 和过程噪声协方差 Q \mathbf{Q} Q 对下一时刻的状态进行预测

  • 计算下一时刻的均值(位置 = 当前位置 + 速度)。
  • 更新协方差矩阵,结合状态转移和过程噪声。
  • 假设宽高比变化极小,速度噪声较低,确保滤波的鲁棒性。
def predict(self, mean: np.ndarray, covariance: np.ndarray) -> tuple:"""Run Kalman filter prediction step.Args:mean (ndarray): The 8-dimensional mean vector of the object state at the previous time step.covariance (ndarray): The 8x8-dimensional covariance matrix of the object state at the previous time step.Returns:(tuple[ndarray, ndarray]): Returns the mean vector and covariance matrix of the predicted state. Unobservedvelocities are initialized to 0 mean.Examples:    x_k+1 = F* x_k  ; P_K+1 = F* p_k * F^T>>> kf = KalmanFilterXYAH()>>> mean = np.array([0, 0, 1, 1, 0, 0, 0, 0])>>> covariance = np.eye(8)>>> predicted_mean, predicted_covariance = kf.predict(mean, covariance)"""std_pos = [self._std_weight_position * mean[3],self._std_weight_position * mean[3],1e-2,self._std_weight_position * mean[3],]     # [0.05, 0.05, 0.01, 0.05]std_vel = [self._std_weight_velocity * mean[3],self._std_weight_velocity * mean

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

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

相关文章

Vue-admin-template安装教程

#今天配置后台管理模板发现官方文档的镜像网站好像早失效了,自己稍稍总结了一下方法# 该项目环境需要node17及以下,如果npm install这一步报错可能是这个原因 git clone https://github.com/PanJiaChen/vue-admin-template.git cd vue-admin-template n…

Rust从入门到精通之进阶篇:14.并发编程

并发编程 并发编程允许程序同时执行多个独立的任务,充分利用现代多核处理器的性能。Rust 提供了强大的并发原语,同时通过类型系统和所有权规则在编译时防止数据竞争和其他常见的并发错误。在本章中,我们将探索 Rust 的并发编程模型。 线程基…

算法训练营第二十三天 | 贪心算法(一)

文章目录 一、贪心算法理论基础二、Leetcode 455.分发饼干二、Leetcode 376. 摆动序列三、Leetcode 53. 最大子序和 一、贪心算法理论基础 贪心算法是一种在每一步选择中都采取当前状态下的最优决策,从而希望最终达到全局最优解的算法设计技术。 基本思想 贪心算…

css基础-display 常用布局

CSS display 属性详解 属性设置元素是否被视为块级或行级盒子以及用于子元素的布局,例如流式布局、网格布局或弹性布局。 一、基础显示模式 1. block 作用: 元素独占一行可设置宽高和内外边距默认宽度撑满父容器 应用场景: 布局容器&a…

速卖通API数据清洗实战:从原始JSON到结构化商品数据库

下面将详细介绍如何把速卖通 API 返回的原始 JSON 数据清洗并转换为结构化商品数据库。 1. 数据获取 首先要借助速卖通 API 获取商品数据,以 Python 为例,可使用requests库发送请求并得到 JSON 数据。 import requests# 替换为你的 API Key 和 Secret …

【零基础入门unity游戏开发——2D篇】2D物理系统 —— 2D刚体组件(Rigidbody2D)

考虑到每个人基础可能不一样,且并不是所有人都有同时做2D、3D开发的需求,所以我把 【零基础入门unity游戏开发】 分为成了C#篇、unity通用篇、unity3D篇、unity2D篇。 【C#篇】:主要讲解C#的基础语法,包括变量、数据类型、运算符、流程控制、面向对象等,适合没有编程基础的…

Collectors.toMap / list 转 map

前言 略 Collectors.toMap List<User> userList ...; Map<Long, User> userMap userList.stream().collect(Collectors.toMap(User::getUserId, Function.identity()));假如id存在重复值&#xff0c;则会报错Duplicate key xxx, 解决方案 两个重复id中&#…

热门面试题第13天|Leetcode 110.平衡二叉树 257. 二叉树的所有路径 404.左叶子之和 222.完全二叉树的节点个数

222.完全二叉树的节点个数&#xff08;优先掌握递归&#xff09; 需要了解&#xff0c;普通二叉树 怎么求&#xff0c;完全二叉树又怎么求 题目链接/文章讲解/视频讲解&#xff1a;https://programmercarl.com/0222.%E5%AE%8C%E5%85%A8%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E8…

关于Object.assign

Object.assign 基本用法 Object.assign() 方法用于将所有可枚举属性的值从一个或者多个源对象source复制到目标对象。它将返回目标对象target const target { a: 1, b: 2 } const source { b: 4, c: 5 }const returnedTarget Object.assign(target, source)target // { a…

GitHub高级筛选小白使用手册

GitHub高级筛选小白使用手册 GitHub 提供了强大的搜索功能&#xff0c;允许用户通过高级筛选器来精确查找仓库、Issues、Pull Requests、代码等。下面是一些常用的高级筛选用法&#xff0c;帮助你更高效地使用 GitHub 搜索功能。 目录 搜索仓库搜索Issues搜索Pull Requests搜…

手动集成sqlite的方法

注意到sqlite有backup方法&#xff08;https://www.sqlite.org/backup.html&#xff09;。 也注意到android中sysroot下&#xff0c;没有sqlite3的库&#xff0c;也没有相关头文件。 如果要使用 sqlite 的backup&#xff0c;那么就需要手动集成sqlite代码到项目中。可以如下操…

蓝桥杯真题 2109.统计子矩阵

原题地址:1.统计子矩阵 - 蓝桥云课 问题描述 给定一个 NMNM 的矩阵 AA, 请你统计有多少个子矩阵 (最小 1111, 最大 NM)NM) 满足子矩阵中所有数的和不超过给定的整数 KK ? 输入格式 第一行包含三个整数 N,MN,M 和 KK. 之后 NN 行每行包含 MM 个整数, 代表矩阵 AA. 输出格…

蓝桥杯—最少操作数

一.题目 分析:每次可以进行三次操作&#xff0c;求在n步操作后可以达到目标数的最小n&#xff0c;和最短路径问题相似&#xff0c;分层遍历加记忆化搜索防止时间复杂度过高&#xff0c;还需要减枝操作 import java.util.HashSet; import java.util.LinkedList; import java.ut…

Linux内核NIC网卡驱动实战案例分析

以下Linux 内核模块实现了一个虚拟网络设备驱动程序&#xff0c;其作用和意义如下&#xff1a; 1. 作用 &#xff08;1&#xff09;创建虚拟网络设备对 驱动程序动态创建了两个虚拟网络设备&#xff08;nic_dev[0]和nic_dev[1]&#xff09;&#xff0c;模拟物理网卡的功能。这两…

Trae初使用心得(Java后端)

1.前提 2025年3月3日&#xff0c;字节跳动正式官宣“中国首个 AI 原生集成开发环境&#xff08;AI IDE&#xff09;”Trae 国内版正式上线&#xff0c;由于之前项目的原因小编没有及时的去体验&#xff0c;这几日专门抽空去体验了一下感觉还算可以。 2.特点 Trade重在可以白嫖…

[项目]基于FreeRTOS的STM32四轴飞行器: 十二.角速度加速度滤波

基于FreeRTOS的STM32四轴飞行器: 十二.滤波 一.滤波介绍二.对角速度进行一阶低通滤波三.对加速度进行卡尔曼滤波 一.滤波介绍 模拟信号滤波&#xff1a; 最常用的滤波方法可以在信号和地之间并联一个电容&#xff0c;因为电容通交隔直&#xff0c;信号突变会给电容充电&#x…

UNIX网络编程笔记:TCP、UDP、SCTP编程的区别

一、核心特性对比 特性TCPUDPSCTP连接方式面向连接&#xff08;三次握手&#xff09;无连接面向连接&#xff08;四次握手&#xff09;可靠性可靠传输&#xff08;重传、确认机制&#xff09;不可靠传输可靠传输&#xff08;多路径冗余&#xff09;传输单位字节流&#xff08;…

Python爬虫异常处理:自动跳过无效URL

爬虫在运行过程中常常会遇到各种异常情况&#xff0c;其中无效URL的出现是较为常见的问题之一。无效URL可能导致爬虫程序崩溃或陷入无限等待状态&#xff0c;严重影响爬虫的稳定性和效率。因此&#xff0c;掌握如何在Python爬虫中自动跳过无效URL的异常处理技巧&#xff0c;对于…

C++语法学习的主要内容

科技特长生方向&#xff0c;主要学习的内容为 一&#xff0c;《C语法》 二&#xff0c;《数据结构》 三&#xff0c;《算法》 四&#xff0c;《计算机基础知识》 五&#xff0c;《初高中的数学知识》 其中&#xff0c;《C语法》学习的主要内容如下: 1,cout输出语句和键盘…

3、孪生网络/连体网络(Siamese Network)

目的: 用Siamese Network (孪生网络) 解决Few-shot learning (小样本学习)。 Siamese Network并不是Meta Learning最好的方法, 但是通过学习Siamese Network,非常有助于理解其他Meta Learning算法。 这里介绍了两种方法:Siamese Network (孪生网络)、Trplet Loss Siam…