资源简介
先对第一帧图像用鼠标框选跟踪区域,双击后开始自动跟踪。代码可以修改来处理图片序列。

代码片段和文件信息
% Adam Kukucka
% Zach Clay
% Marcelo Molina
% CSE 486 Project 3
%function [ trackmov probmov centers ] = camshift
% ******************************************************************
% initialize vari ables
% ******************************************************************
rmin = 0; %min row value for search window
rmax = 0; %max row value for search window
cmin = 0; %min col value for search window
cmax = 0; %max col value for search window
numofframes = 144; %number of frames in the avi
threshold = 1; %threshold for convergence
centerold = [0 0]; %for convergence... previous center of window
centernew = [0 0]; %for convergence... new center of window
% ******************************************************************
% Pre code... load movie and select initial frame
% ******************************************************************
% prompt user for avi file name
%user_entry = input(‘Please enter an avi filename: ‘‘s‘);
% load the avi file... handle is M
% avi = VideoReader(‘E:\数据库\视频\in_1.AVI‘);
% numberofframes = avi.NumberOfframes;
numberofframes=610;
% get number of frames
% initialize matrix to hold center coordinates
imagecenters = zeros(numofframes 2);
% extract the first frame from the avi
% Image1 = read(avi1);
Image1 = imread(‘E:\数据库\视频\Walk1Data\46.jpg‘);
%%% ********** images(: : numberofframes) = G(::);
% get search window for first frame
[picrec]=imcrop(Image1);
%[ cmin cmax rmin rmax ] = select( Image1);
cmin = round(rec(11));
cmax = round(rec(11)+rec(13));
rmin = round(rec(12));
rmax = round(rec(12)+rec(14));
wsize(1) = abs(rmax - rmin);
wsize(2) = abs(cmax - cmin);
% create histogram
% translate to hsv
hsvimage = rgb2hsv(Image1);
% pull out the h
huenorm = hsvimage(::1);
% scale to 0 to 255
hue = huenorm*255;
% set unit type
hue=uint8(hue);
% Getting Histogram of Image:
histogram = zeros(256);
for i=rmin:rmax
for j=cmin:cmax
index = uint8(hue(ij)+1);
%count number of each pixel
histogram(index) = histogram(index) + 1;
end
end
% ******************************************************************
% Algorithm from pdf
% ******************************************************************
% aviobj1 = avifile(‘2.avi‘);
% aviobj2 = avifile(‘3.avi‘);
% for each frame
for n = 46:numberofframes
frame=strcat(‘E:\数据库\视频\Walk1Data\‘num2str(n)‘.jpg‘);
I=imread(frame); % 依次读入各帧图像
% I=read(avin);
% translate to hsv
hsvimage = rgb2hsv(I);
% pull out the h
huenorm = hsvimage(::1);
% scale to 0 to 255
hue = huenorm*255;
% set unit type
hue=uint8(hue);
[rows cols] = size(hue);
% choose initial search window
% the search window is (cmin rmin) to (cmax rmax)
% create a probability map
probmap = zeros(rows cols);
for r=1:rows
for c=1:cols
if(hue(rc) ~= 0)
probmap(rc)= histogram(hue(rc));
end
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1272 2013-10-23 19:52 meanshift.m
文件 6062 2013-10-24 10:03 camshift.m
----------- --------- ---------- ----- ----
7334 2
- 上一篇:逆变器下垂控制simuli
nk仿真程序 - 下一篇:近邻传播聚类-MATLAB程序
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论