基于Mean_shift的运动目标跟踪算法高速公路车辆的检测源码程序 - matlab算法设计 - 谷速源码
下载频道> 资源分类> matlab源码> 算法设计> 基于Mean_shift的运动目标跟踪算法高速公路车辆的检测源码程序

标题:基于Mean_shift的运动目标跟踪算法高速公路车辆的检测源码程序
分享到:

所属分类: 算法设计 资源类型:程序源码 文件大小: 14.87 MB 上传时间: 2019-12-01 23:05:16 下载次数: 53 资源积分:1分 提 供 者: jiqiren 20191201110617744
内容:
基于Mean_shift的运动目标跟踪算法,可实现高速公路车辆的检测
% ----------------------------------------------------------------------
% - CSE 486
% - Project 5
% - Group 8
% - idg101, adi102, jlm522
% ----------------------------------------------------------------------
 
clc;
disp('Running...');
close all;
clear;
cd frames;
 
% ----------------------------------------------------------------------
% Constants
    WHITE = 255;
 
    % Threshold of convergence (in pixels for each deg. of freedom)
T = 1;
    
    % Number of pixels to expand search window by.
    P = 5;
 
% ----------------------------------------------------------------------
% Mean Shift
 
avi = avifile('output12.avi');
 
% Initial search window size.
%W = [10 10];
W = [80 94];
 
% Initial location of search window.
%L = [95 193];
L = [71 141];
 
% For plotting motion
Xpoints=[];
Ypoints=[];
 
disp('Frame: Coordinates');
 
for frame = 1:6
% filename = sprintf('%3.3i.png', frame);
% R = imread(filename, 'png');
 
filename = sprintf('OUTPUT_000%3.3i.bmp', frame+11);
R = imread(filename, 'bmp');
    
% Convert image from RGB space to HSV space
I = rgb2hsv(R);
 
% Extract the hue information
I = I(:,:,1);
    I = roicolor(I, 0.83, 1.0);
    
    % Initialization
    oldCamL = [0 0];
    MeanConverging = 1;
% ----------------------------------------------------------------------
    % Create search window box on image.
    for i = L(1) : L(1)+W(1),
        x = i;
        y = L(2);
        if x > size(I,1) | y > size(I,2) | x < 1 | y < 1
            continue;
        else
            R(x, y,:) = 0;
        end
    end
    
    for i = L(1) : L(1)+W(1),
        x = i;
        y = L(2) + W(2);
        if x > size(I,1) | y > size(I,2) | x < 1 | y < 1
            continue;
        else
            R(x, y, :) = 0;
        end
    end    
    
    for i = L(2) : L(2)+W(2),
        x = L(1);
        y = i;
        if x > size(I,1) | y > size(I,2) | x < 1 | y < 1
            continue;
        else
            R(x, y, :) = 0;
        end
    end    
 
    for i = L(2) : L(2)+W(2),
        x = L(1)+W(1);
        y = i;
        if x > size(I,1) | y > size(I,2) | x < 1 | y < 1
            continue;
        else
            R(x, y, :) = 0;
        end
    end    
% ----------------------------------------------------------------------  
    while MeanConverging,
        % Compute centroid of search window
M00 = 0.0;
for i = L(1)-P : (L(1)+W(1)+P),
            for j = L(2)-P : (L(2)+W(2)+P),
                if i > size(I,1) | j > size(I,2) | i < 1 | j < 1
                    continue;
                end
                M00 = M00 + double(I(i,j));
            end
end
 
M10 = 0.0;
for i = L(1)-P : (L(1)+W(1)+P),
            for j = L(2)-P : (L(2)+W(2)+P),
                if i > size(I,1) | j > size(I,2) | i < 1 | j < 1
                    continue;
                end
                M10 = M10 + i * double(I(i,j));
            end
end
 
M01 = 0.0;
for i = L(1)-P : (L(1)+W(1)+P),
            for j = L(2)-P : (L(2)+W(2)+P),
                if i > size(I,1) | j > size(I,2)| i < 1 | j < 1
                    continue;
                end                
                M01 = M01 + j * double(I(i,j));
            end
end
 
xc = round(M10 / M00);
yc = round(M01 / M00);
 
oldL = L;
L = [floor(xc - (W(1)/2)) floor(yc - (W(2)/2))];
       
        % Check threshold
        if abs(oldL(1)-L(1)) < T | abs(oldL(2)-L(2)) < T
            MeanConverging = 0;
        end
    end
    
    % We now know the centroid and M00.
    % This information is used to alter the search window size.
    
    % Adjust window size
    s = round(1.1 * sqrt(M00));
    W = [ s      floor(1.2*s) ];
    L = [floor(xc - (W(1)/2)) floor(yc - (W(2)/2))];
    
    % Output the centroid's coordinates
    disp(sprintf('%3i:   %3i, %3i', frame, xc, yc));
    Xpoints = [Xpoints xc];
    Ypoints = [Ypoints yc];
    
    % Superimpose plus sign on to centroid of hand.
    plus_sign_mask = [0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     1 1 1 1 1 1 1 1 1 1 1 1 1;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0;
                     0 0 0 0 0 0 1 0 0 0 0 0 0];
sizeM = size(plus_sign_mask);
for i = -floor(sizeM(1) / 2):floor(sizeM(1) / 2),
        for j = -floor(sizeM(2) / 2):floor(sizeM(2) / 2),
            if plus_sign_mask(i+1+floor(sizeM(1) / 2), j+1+floor(sizeM(2) / 2)) == 1
                R(i+xc, j+yc, :) = WHITE;
            end
        end
end
% ----------------------------------------------------------------------
    % Display the probability image.
    I = rgb2hsv(R);
    S = [];
    S(:,:,1) = I(:,:,1);
    S(:,:,2) = I(:,:,1);    
    S(:,:,3) = I(:,:,1);
    
% Extract the hue information
    avi = addframe(avi, S);
    
end
 
disp('AVI move parameters:');
avi = close(avi)
% ----------------------------------------------------------------------
plot(Ypoints,Xpoints, 'go' , Ypoints, Xpoints);
axis([0 320 0 240]);
 
 
% ----------------------------------------------------------------------
cd ..
disp('Done.');
% ----------------------------------------------------------------------

文件列表(点击上边下载按钮,如果是垃圾文件请在下面评价差评或者投诉):

frames/
mean_shift/
camshift.m
drawrect.m
example.avi
frames.rar
frames/OUTPUT_000001.bmp
frames/OUTPUT_000002.bmp
frames/OUTPUT_000003.bmp
frames/OUTPUT_000004.bmp
frames/OUTPUT_000005.bmp
frames/OUTPUT_000006.bmp
frames/OUTPUT_000007.bmp
frames/OUTPUT_000008.bmp
frames/OUTPUT_000009.bmp
frames/OUTPUT_000010.bmp
frames/OUTPUT_000011.bmp
frames/OUTPUT_000012.bmp
frames/OUTPUT_000013.bmp
frames/OUTPUT_000014.bmp
frames/OUTPUT_000015.bmp
frames/OUTPUT_000016.bmp
frames/OUTPUT_000017.bmp
frames/OUTPUT_000018.bmp
frames/OUTPUT_000019.bmp
frames/OUTPUT_000020.bmp
frames/OUTPUT_000021.bmp
frames/OUTPUT_000022.bmp
frames/OUTPUT_000023.bmp
frames/OUTPUT_000024.bmp
frames/OUTPUT_000025.bmp
frames/OUTPUT_000026.bmp
frames/OUTPUT_000027.bmp
frames/OUTPUT_000028.bmp
frames/OUTPUT_000029.bmp
frames/OUTPUT_000030.bmp
frames/OUTPUT_000031.bmp
frames/OUTPUT_000032.bmp
frames/OUTPUT_000033.bmp
frames/OUTPUT_000034.bmp
frames/OUTPUT_000035.bmp
frames/OUTPUT_000036.bmp
frames/OUTPUT_000037.bmp
frames/OUTPUT_000038.bmp
frames/OUTPUT_000039.bmp
frames/OUTPUT_000040.bmp
frames/OUTPUT_000041.bmp
frames/OUTPUT_000042.bmp
frames/OUTPUT_000043.bmp
frames/OUTPUT_000044.bmp
frames/OUTPUT_000045.bmp
frames/OUTPUT_000046.bmp
frames/OUTPUT_000047.bmp
frames/OUTPUT_000048.bmp
frames/OUTPUT_000049.bmp
frames/OUTPUT_000050.bmp
frames/OUTPUT_000051.bmp
frames/OUTPUT_000052.bmp
frames/OUTPUT_000053.bmp
frames/OUTPUT_000054.bmp
getrect.m
hand-probability.avi
hand-rgb.avi
part1.m
trackingext.m

关键词: Mean_shift 运动 目标 跟踪 算法 高速公路 车辆 检测 源码 程序

Top_arrow
回到顶部
联系方式| 版权声明| 招聘信息| 广告服务| 银行汇款| 法律顾问| 兼职技术| 付款方式| 关于我们|
网站客服网站客服 程序员兼职招聘 程序员兼职招聘
沪ICP备19040327号-3
公安备案号:沪公网安备 31011802003874号
库纳格流体控制系统(上海)有限公司 版权所有
Copyright © 1999-2014, GUSUCODE.COM, All Rights Reserved