当前位置: 首页 > article >正文

目标跟踪——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

相关文章:

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

deepsort 算法详解 Unmatched Tracks(未匹配的轨迹) 本质角色: 是已存在的轨迹在当前帧中“失联”的状态,即预测位置与检测结果不匹配。 生命周期阶段: 已初始化: 轨迹已存在多帧,可能携带历史信息(如外观特征、运动模型)。 未被观测到: 当前帧中未找到对应的检测框…...

AI Agent 是什么?从 Chatbot 到自动化 Agent(LangChain、AutoGPT、BabyAGI)

1. 引言:AI Agent 的演进 AI Agent(人工智能智能体)是 AI 发展的重要方向之一。早期的 AI 主要以 Chatbot 形式存在,如客服机器人、智能助手等,主要基于 NLP 技术进行任务处理。而随着大模型(LLM)能力的提升,AI Agent 逐步演进为能够自主执行任务的智能体,如 AutoGPT…...

ngx_http_core_root

定义在 src\http\ngx_http_core_module.c static char * ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {ngx_http_core_loc_conf_t *clcf conf;ngx_str_t *value;ngx_int_t alias;ngx_uint_t …...

python康复日记-request库的使用,爬虫自动化测试

一,request的简单应用 #1请求地址 URLhttps://example.com/login #2参数表单 form_data {username: admin,password: secret } #3返回的响应对象response response requests.post(URL,dataform_data,timeout5 ) #4处理返回结果,这里直接打印返回网页的…...

光谱范围与颜色感知的关系

光谱范围与颜色感知是光学、生理学及技术应用交叉的核心课题,两者通过波长分布、人眼响应及技术处理共同决定人类对色彩的认知。以下是其关系的系统解析: ‌1.基础原理:光谱范围与可见光‌ ‌光谱范围定义‌: 电磁波谱中能被特定…...

OpenCV vs MediaPipe:哪种方案更适合实时手势识别?

引言 手势识别是计算机视觉的重要应用,在人机交互(HCI)、增强现实(AR)、虚拟现实(VR)、智能家居控制、游戏等领域有广泛的应用。实现实时手势识别的技术方案主要有基于传统计算机视觉的方法&am…...

el-select下拉框,搜索时,若是匹配后的数据有且只有一条,则当失去焦点时,默认选中该条数据

1、使用指令 当所需功能只能通过直接的 DOM 操作来实现时&#xff0c;才应该使用自定义指令。可使用方法2封装成共用函数&#xff0c;但用指令他人复用时比较便捷。 <el-tablev-loading"tableLoading"border:data"tableList"default-expand-allrow-key…...

网络地址转换技术(2)

NAT的配置方法&#xff1a; &#xff08;一&#xff09;静态NAT的配置方法 进入接口视图配置NAT转换规则 Nat static global 公网地址 inside 私网地址 内网终端PC2&#xff08;192.168.20.2/24&#xff09;与公网路由器AR1的G0/0/1&#xff08;11.22.33.1/24&#xff09;做…...

Python正则表达式(一)

目录 一、正则表达式的基本概念 1、基本概念 2、正则表达式的特殊字符 二、范围符号和量词 1、范围符号 2、匹配汉字 3、量词 三、正则表达式函数 1、使用正则表达式&#xff1a; 2、re.match()函数 3、re.search()函数 4、findall()函数 5、re.finditer()函数 6…...

【TI MSPM0】PWM学习

一、样例展示 #include "ti_msp_dl_config.h"int main(void) {SYSCFG_DL_init();DL_TimerG_startCounter(PWM_0_INST);while (1) {__WFI();} } TimerG0输出一对边缘对齐的PWM信号 TimerG0会输出一对62.5Hz的边缘对齐的PWM信号在PA12和PA13引脚上&#xff0c;PA12被…...

MySQL: 创建两个关联的表,用联表sql创建一个新表

MySQL: 创建两个关联的表 建表思路 USERS 表&#xff1a;包含用户的基本信息&#xff0c;像 ID、NAME、EMAIL 等。v_card 表&#xff1a;存有虚拟卡的相关信息&#xff0c;如 type 和 amount。关联字段&#xff1a;USERS 表的 V_CARD 字段和 v_card 表的 v_card 字段用于建立…...

更改 vscode ! + table 默认生成的 html 初始化模板

vscode ! 快速成的 html 代码默认为&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>D…...

使用LVS的 NAT 模式实现 3 台RS的轮询访问

节点规划 1、配置RS RS的网络配置为NAT模式&#xff0c;三台RS的网关配置为192.168.10.8 1.1配置RS1 1.1.1修改主机名和IP地址 [rootlocalhost ~]# hostnamectl hostname rs1 [rootlocalhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.10.7/24…...

R 基础语法

R 基础语法 引言 R 是一种针对统计计算和图形表示而设计的编程语言和环境。它广泛应用于统计学、生物信息学、数据挖掘等领域。本文将为您介绍 R 语言的基础语法,帮助您快速上手。 R 的基本结构 R 语言的基本结构包括:变量、数据类型、运算符、控制结构、函数等。 变量 …...

MySQL实战(尚硅谷)

要求 代码 # 准备数据 CREATE DATABASE IF NOT EXISTS company;USE company;CREATE TABLE IF NOT EXISTS employees(employee_id INT PRIMARY KEY,first_name VARCHAR(50),last_name VARCHAR(50),department_id INT );DESC employees;CREATE TABLE IF NOT EXISTS departments…...

华为p10 plus 鸿蒙2.0降级emui9.1.0.228

需要用到的工具 HiSuite Proxy V3 华为手机助手11.0.0.530_ove或者11.0.0.630_ove应该都可以。 官方的通道已关闭&#xff0c;所以要用代理&#xff0c;127.0.0.1端口7777 https://www.firmfinder.ml/ https://professorjtj.github.io/v2/ https://hisubway.online/articl…...

C# Modbus RTU学习记录

继C# Modbus TCP/IP学习记录后&#xff0c;尝试串口通信。 操作步骤&#xff1a; 1.使用Visual Studio安装Nuget包NModbus.Serial。 2.使用Modbus Slave应用程序&#xff0c;工具栏Connection项&#xff0c;单击Connect&#xff0c;弹窗Connection Setup&#xff0c;修改Con…...

AI+Xmind自动生成测试用例(思维导图格式)

一、操作步骤: 步骤1:创建自动生成测试用例智能体 方式:使用通义千问/豆包智能体生成,以下两个是我已经训练好的智能体,直接打开使用即可 通义智能体: https://lxblog.com/qianwen/share?shareId=b0cd664d-5001-42f0-b494-adc98934aba5&type=agentCard 豆包智能…...

单片机 - 位运算详解(``、`|`、`~`、`^`、`>>`、`<<`)

单片机中的位运算详解&#xff08;&、|、~、^、>>、<<&#xff09; 位运算是单片机编程&#xff08;C/C&#xff09;中经常使用的技巧&#xff0c;用于高效地操作寄存器、I/O 端口和数据。以下是各位运算符的详细解析&#xff0c;并结合单片机实际应用举例。 …...

chrome插件开发之API解析-chrome.tabs.query

chrome.tabs.query 是 Chrome 扩展开发中用于查询浏览器标签页信息的 API。它允许你根据指定的条件获取当前浏览器中所有匹配的标签页。这个 API 返回一个 Promise&#xff0c;解析后会得到一个包含匹配标签页信息的数组。 常见用途 获取当前活动标签页&#xff1a;可以获取当…...

(二)手眼标定——概述+原理+常用方法汇总+代码实战(C++)

一、手眼标定简述 手眼标定的目的&#xff1a;让机械臂和相机关联&#xff0c;相机充当机械臂的”眼睛“&#xff0c;最终实现指哪打哪 相机的使用前提首先需要进行相机标定&#xff0c;可以参考博文&#xff1a;&#xff08;一&#xff09;相机标定——四大坐标系的介绍、对…...

3D点云的深度学习网络分类(按照作用分类)

1. 3D目标检测&#xff08;Object Detection&#xff09; 用于在点云中识别和定位目标&#xff0c;输出3D边界框&#xff08;Bounding Box&#xff09;。 &#x1f539; 方法类别&#xff1a; 单阶段&#xff08;Single-stage&#xff09;&#xff1a;直接预测3D目标位置&am…...

【Linux网络-NAT、代理服务、内网穿透】

一、NAT技术 1.NAT技术背景 之前我们讨论了&#xff0c;IPV4协议中&#xff0c;IP地址数量不充足的问题 NAT技术当前解决IP地址不够用的主要手段&#xff0c;是路由器的一个重要功能 NAT&#xff08;网络地址转换&#xff0c;Network Address Translation&#xff09;是一种…...

Windows 和 Linux 操作系统架构对比以及交叉编译

操作系统与架构兼容性详解 1. 可执行文件格式&#xff1a;PE vs ELF Windows: PE (Portable Executable) 格式 详细解释&#xff1a; PE 格式是 Windows 下的可执行文件标准 包含多个区段&#xff08;Sections&#xff09;&#xff0c;如代码段、数据段、资源段 文件头包含…...

heapq库的使用——python代码

Python中heapq库的基础使用方法和示例代码&#xff0c;包含详细注释说明&#xff1a; 1. 基本功能 heapq 实现的是最小堆&#xff08;父节点值 ≤ 子节点值&#xff09;&#xff0c;核心操作包括&#xff1a; 插入元素&#xff1a;heappush(heap, item)弹出最小值&#xff1a…...

新手村:逻辑回归-理解02:逻辑回归中的伯努利分布

新手村&#xff1a;逻辑回归-理解02&#xff1a;逻辑回归中的伯努利分布 伯努利分布在逻辑回归中的潜在含义及其与后续推导的因果关系 1. 伯努利分布作为逻辑回归的理论基础 ⭐️ 逻辑回归的核心目标是: 建模二分类问题中 目标变量 y y y 的概率分布。 伯努利分布&#xff08…...

golang Error的一些坑

golang Error的一些坑 golang error的设计可能是被人吐槽最多的golang设计了。 最经典的err!nil只影响代码风格设计&#xff0c;而有一些坑会导致我们的程序发生一些与我们预期不符的问题&#xff0c;开发过程中需要注意。 ​​ errors.Is​判断error是否Wrap不符合预期 ​…...

【干货,实战经验】nginx缓存问题

文章目录 案例背景出现的问题:定位到问题解决方式修改配置修改后的nginx配置 案例背景 有2个服务器A 和B&#xff0c;A是一个动态ip经常变公网ip&#xff0c;B是一个云服务器&#xff0c;公网ip固定. 于是我通过ddns &#xff0c;找了个域名C&#xff0c;动态解析A服务器上的公…...

分布式理论:CAPBASE理论

1 CAP理论 1.1 简介 CAP也就是Consistency&#xff08;一致性&#xff09;、Availability&#xff08;可用性&#xff09;、Partition Tolenrance&#xff08;分区容错性&#xff09;这三个单词首字母组合。 在理论计算机科学中&#xff0c;CAP定理&#xff08;CAP theorem&…...

大数据学习(86)-Zookeeper去中心化调度

&#x1f34b;&#x1f34b;大数据学习&#x1f34b;&#x1f34b; &#x1f525;系列专栏&#xff1a; &#x1f451;哲学语录: 用力所能及&#xff0c;改变世界。 &#x1f496;如果觉得博主的文章还不错的话&#xff0c;请点赞&#x1f44d;收藏⭐️留言&#x1f4dd;支持一…...