## 《计算机视觉》
## 基于 SIFT 和 KCF 的运动目标匹配与跟踪
# 一、摘要
本次编程实验我们从日常生活出发,运用计算机视觉算法解决实际问题。我们利用 SIFT 与 KCF 实现了运动目标的识别匹配与跟踪。该算法有着很广的应用,如无人机跟拍、导弹追踪目标、追踪人手实现人机交互等。我们的程序模拟了无人机跟拍的过程,此外,我们还开发了一款游戏,无须使用键盘和鼠标,利用摄像头追踪手的位置实现人在游戏中的操作。
# 二、应用背景与任务描述
## 2.1 应用背景
目标检测匹配与跟踪算法有着很广的应用,如无人机自动跟拍、导弹追踪目标、追踪人手实现人机交互等。
## 2.2 任务描述
- 给定目标(以一张图片的方式方程告诉程序),要求程序能够根据所给目标的图片实时跟踪该目标在一段视频中的位置。
- 实现一个简单的飞机扫射游戏,计算机通过内置摄像头跟踪玩家的手,玩家通过移动手部,可以实现对游戏中的飞机的操控。
# 三、问题分析
上述两个任务的核心都是需要在视频中检测出特定目标并跟踪。对于检测,需要把给定的目标图像与现在程序捕获到的一帧视频中的目标进行匹配。为了提高匹配的精度,并且让匹配有较好的鲁棒性,需要选择合适的特征。我们选择了 SIFT 特征,由于 SIFT 描述子的检测速度较慢,无法满足实时性,因此我们只在第一帧图像中使用了 SIFT 检测算法。我们假设目标在第一帧出现,那么当程序在第一帧检测出目标并框出后,由于我们的目的是跟踪这个特定目标,因此只要在第一帧检测到目标,剩下的任务就可以交给跟踪算法,而不需要每一帧都进行目标检测。我们选择了 KCF 作为跟踪算法,KCF 具有较好的精度和极好的实时性。通过跟踪得到结果后,进行显示等处理。对于处理视频,在视频每一帧中把框画出,在游戏中,根据跟踪得到的位置映射到游戏内部的操作。
![](https://www.writebug.com/myres/static/uploads/2021/11/24/90425ade3fb7c4fc7c7e3c4540145a55.writebug)
# 四、算法原理
## 4.1 目标检测与匹配
### 4.1.1 SIFT 综述
SIFT 的全称是 Scale Invariant Feature Transform,即尺度不变特征变换,由英属哥伦比亚大学教授 David G. Lowe 提出。SIFT 特征具有旋转、尺度、亮度变化不变性,是一种非常稳定的局部特征。SIFT 算法的实质是在不同的尺度空间上查找特征点,并计算出特征点的方向。SIFT 所查找到的特征点是一些十分突出,不会因光照,仿射变换和噪音等因素而变化的点,如角点、边缘点、暗区的亮点及亮区的暗点等。
### 4.1.2 尺度空间极值检测
首先对图像做不同尺度的高斯模糊
![](https://www.writebug.com/myres/static/uploads/2021/11/24/323883403f644664011c1f3084ea4389.writebug)
以及对图像做降采样,构造高斯金字塔,然后利用同一组内图像做差
![](https://www.writebug.com/myres/static/uploads/2021/11/24/b610b2e1ae8575c33cba183f0906282c.writebug)
构造高斯差分(DoG)金字塔。对 DoG 金字塔中的每一像素,在三维邻域(两维图像、一维尺度)内判断是否为极值点,可以确定极值点的位置及尺度,极值的大小反映了极值处的对比度(反差)。
![](https://www.writebug.com/myres/static/uploads/2021/11/24/112dd26954ed38cac28017bcc5ec5a0e.writebug)
![](https://www.writebug.com/myres/static/uploads/2021/11/24/1917ca2a67dd5f1bc6901951cf565413.writebug)
![](https://www.writebug.com/myres/static/uploads/2021/11/24/cc9ce4fc466ad6217569403ac5e9aef6.writebug)
### 4.1.3 关键点定位
由于图像是离散化的,真正的极值点并不一定在整数点上,因此进行亚像素(子像素)精确定位:将原点移到极值点处,并将高斯差分在该极值点处展开,保留一阶项及二阶项,得到:
![](https://www.writebug.com/myres/static/uploads/2021/11/24/f626b6f3af08e64966264951d261b62f.writebug)
其中
![](https://www.writebug.com/myres/static/uploads/2021/11/24/96d1c1ca03badf6e68b21a4339a17b0c.writebug)
。
令
![](https://www.writebug.com/myres/static/uploads/2021/11/24/240c69f5def4b72546df98449b16b423.writebug)
,得:
![](https://www.writebug.com/myres/static/uploads/2021/11/24/ced795cdd277251dadd9f1694d1e9961.writebug)
![](https://www.writebug.com/myres/static/uploads/2021/11/24/f14fc5d9ab72ff612ce2dcd129c1bc51.writebug)
去除对比度较低的不稳定极值点:利用
![](https://www.writebug.com/myres/static/uploads/2021/11/24/e588e26ec2c447a4a9c29f3356116866.writebug)
处的高斯差分值
![](https://www.writebug.com/myres/static/uploads/2021/11/24/d9bbbb30c6b51f60fec17144ad8cc630.writebug)
,设对比度阈值为
![](https://www.writebug.com/myres/static/uploads/2021/11/24/5caae605b81413958e511c6008f935ff.writebug)
,则当
![](https://www.writebug.com/myres/static/uploads/2021/11/24/ec6b87e9807db74f55b28d0fb58797c9.writebug)
时,去除极值点
![](https://www.writebug.com/myres/static/uploads/2021/11/24/c08b06e8df517f292d6cf2fbe69b0565.writebug)
。
去除边缘点:由于 DoG 算子对边缘点也很敏感,在边缘处也有很大的响应值。利用 Hessian 矩阵来处理边缘点。在极值点处,利用
![](https://www.writebug.com/myres/static/uploads/2021/11/24/87f9ecb9bb79762287ced71f3b74cf22.writebug)
计算 Hessian 矩阵
![](https://www.writebug.com/myres/static/uploads/2021/11/24/00e8c78b58156ea5e2bc98e47aa582c2.writebug)
![](https://www.writebug.com/myres/static/uploads/2021/11/24/ef6fc4eb382007aec05c7f69ce6402d3.writebug)
的主曲率,在边缘梯度的方向上比较大,而在沿着边缘的方向上则较小,且与
![](https://www.writebug.com/myres/static/uploads/2021/11/24/287b92f4a0520d7544405c9063dab35e.writebug)
的特征值成正比。利用矩阵
![](https://www.writebug.com/myres/static/uploads/2021/11/24/beb05eeacdf32234eec6a7c5ffa03a7c.writebug)
两个特征值的和等于
![](https://www.writebug.com/myres/static/uploads/2021/11/24/cfa44dbcd5d29618a19a16bf35b60bc5.writebug)
的迹,两个特征值的积等于
![](https://www.writebug.com/myres/static/uploads/2021/11/24/ad8b15f1ad3eec046c9b0f4faeb8e0b3.writebug)
的行列式,有
![](https://www.writebug.com/myres/static/uploads/2021/11/24/39edc4f53111b28bbbc2a36ede8be181.writebug)
其中
![](https://www.writebug.com/myres/static/uploads/2021/11/24/8b3c6c88dc3b817cb798b79ff7a271e5.writebug)
为
![](https://www.writebug.com/myres/static/uploads/2021/11/24/3690c5afbc44e9e2e3bd7bf97c8939f6.writebug)
的大特征值与小特征值之比。
设关于
![](https://www.writebug.com/myres/static/uploads/2021/11/24/35f69c4dcd286c9bf22d36c8e21fda49.writebug)
的阈值为
![](https://www.writebug.com/myres/static/uploads/2021/11/24/a4d53f0f6ecd8853e1d0b6d179c0714e.writebug)
,则当
![](https://www.writebug.com/myres/static/uploads/2021/11/24/06e5823c6fd8471cfa2737c185c3a6d3.writebug)
时,判断该极值点为边缘点,并去除。
### 4.1.4 获取关键点主方向
根据关键点的尺度,在高斯金字塔对应图像的关键点位置处的局部区域计算梯度方向直方图。直方图峰值对应得方向即为关键点的主方向。
![](https://www.writebug.com/myres/static/uploads/2021/11/24/c722e13998eee7368e98b55f32f99b05.writebug)
### 4.1.5 关键点描述
首先确定用于计算关键点描述的局部区域,然后根据关键点主方向变换坐标系,在局部区域内对每个像素点求其梯度幅值和方向,生成方向直方图,最后为克服光照影响,将描述子向量归一化。
![](https://www.writebug.com/myres/static/uploads/2021/11/24/fa4b79df150d1a94efef1b335e7f080f.writebug)
![](https://www.writebug.com/myres/static/
没有合适的资源?快使用搜索试试~ 我知道了~
Python实现的基于SIFT和KCF的运动目标匹配与跟踪
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共118个文件
png:89个
py:22个
md:2个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
11 下载量 184 浏览量
2023-01-31
09:33:42
上传
评论 1
收藏 38.28MB ZIP 举报
温馨提示
本项目为使用Python实现的基于SIFT和KCF的运动目标匹配与跟踪。该算法有着很广的应用,如无人机跟拍、导弹追踪目标、追踪人手实现人机交互等。我们的程序模拟了无人机跟拍的过程。
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/DOCX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PDF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 118 条
- 1
- 2
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/8026cd45bb2448efa9c5fd5e435b208c_qq_38735017.jpg!1)
甜辣uu
- 粉丝: 8802
- 资源: 1102
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)