资源简介
matlab官方所提供的基于卡尔曼滤波的目标跟踪算法demo,核心部分使用了计算机视觉工具箱,本人将其简化并加入汉语注释,使其更加通俗易懂,运行环境为matlab2014
代码片段和文件信息
clc;
frame = [];
detectedLocation = []; %检测到的位置
trackedLocation = []; %跟踪到的位置
label = ‘‘; %球的标签
motionModel = ‘ConstantAcceleration‘; %运动模式
initialLocation = ‘Same as first detection‘; %初始化位置
initialEstimateError = 1E5 * ones(1 3); %初始化估算误差
motionNoise = [25 10 1]; %运动噪声
measurementNoise = 25; %测量噪声
segmentationThreshold = 0.05; %分割阈值
videoReader = vision.VideoFileReader(‘movie.avi‘);
videoPlayer = vision.VideoPlayer(‘Position‘ [100100500400]);
foregroundDetector = vision.ForegroundDetector(... %前景色探测器
‘NumTrainingframes‘ 10 ‘InitialVariance‘ segmentationThreshold);
blobAnalyzer = vision.BlobAnalysis(‘AreaOutputPort‘ false ...
‘MinimumBlobArea‘ 70 ‘CentroidOutputPort‘ true);
accumulatedImage = 0; %累积的图片
accumulatedDetections = zeros(0 2); %累积的探测值
accumulatedTrackings = zeros(0 2); %累积的踪迹
isTrackInitialized = false;
while ~isDone(videoReader)
frame = step(videoReader);
grayImage = rgb2gray(frame); %图像灰度化
foreground = step(foregroundDetector grayImage);
detectedLocation = step(blobAnalyzer foreground);
if isempty(detectedLocation)
isobjectDetected = false;
else
isobjectDetected = true;
detectedLocation = detectedLocation(1 :);
end
if ~isTrackInitialized
if isobjectDetected
if strcmp(initialLocation ‘Same as first detection‘)
initialLocation = detectedLocation;
end
kalmanFilter = configureKalmanFilter(motionModel ...
initialLocation initialEstimateError ...
motionNoise measurementNoise);
isTrackInitialized = true;
trackedLocation = correct(kalmanFilter detectedLocation);
label = ‘Initial‘;
else
trackedLocation = [];
label = ‘‘;
end
else
if isobjectDetected
predict(kalmanFilter);
trackedLocation = correct(kalmanFilter detectedLocation);
label = ‘Corrected‘;
else
trackedLocation = predict(kalmanFilter);
label = ‘Predicted‘;
end
end
accumulatedImage = max(accumulatedImage frame);
accumulatedDetections = [accumulatedDetections; detectedLocation];
accumulatedTrackings = [accumulatedTrackings; trackedLocation];
combinedImage = max(repmat(foreground [113]) frame);
if ~isempty(trackedLocation)
shape = ‘circle‘;
region = trackedLocation;
region(: 3) = 5;
combinedImage = insertobjectAnnotation(combinedImage shape ...
region {label} ‘Color‘ ‘red‘
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-06-11 10:47 kalman目标跟踪\
文件 3424 2016-04-30 09:50 kalman目标跟踪\demoForTracking.m
文件 23405568 2012-05-12 06:37 kalman目标跟踪\movie.avi
文件 8704 2016-06-11 10:47 kalman目标跟踪\Thumbs.db
- 上一篇:雷达回波信号建模与仿真研究
- 下一篇:人脸表情识别matlab代码
相关资源
- 基于粒子滤波的视频目标跟踪算法m
- 基于Meanshift的单目标跟踪算法matlab及
- matlab多目标跟踪算法及数据集
- 单模型机动目标跟踪算法的仿真研究
- 目标跟踪定位算法的matlab程序
- 基于卡尔曼滤波的2d目标跟踪算法 M
- 基于MeanShift的目标跟踪算法
- JPDA 雷达目标跟踪算法源程序
- 均值漂移目标跟踪算法
- 目标跟踪算法KCF加入APCE评价标准的
- 双基地MIMO雷达目标跟踪算法matlab程序
- LSH 局部敏感直方图的目标跟踪算法
- 基于Meanshift的单目标跟踪算法
-
multiple_ob
ject_tracking(3D) 多目标跟 - 基于Lucas-kanade目标跟踪算法
评论
共有 条评论