- 6
- 0
- 约9.08千字
- 约 8页
- 2017-08-02 发布于湖北
- 举报
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%顶层函数camshift%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adam Kukucka
% Zach Clay
% Marcelo Molina
% CSE 486 Project 3
function [ trackmov probmov centers ] = camshift
%用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 = 0; %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视频文件
M = aviread(G:\test.avi);
% get number of frames
%获取该视频文件的总帧数numberofframes
[dontneed numberofframes] = size(M);
% initialize matrix to hold center coordinates
%创建矩阵imagecenters,用于存放每一帧的图像质心坐标
imagecenters = zeros(numberofframes, 2);
% extract the first frame from the avi
%把视频文件的第一帧转化成图像Image1
Frame1 = M(1,1);
Image1 = frame2im(Frame1);
%%% ********** images(:, :, numberofframes) = G(:,:);
% get search window for first frame
%调用自定义的目标选定函数select(),得到目标矩形左上角右下角坐标(取整的)
[ cmin, cmax, rmin, rmax ] = select( Image1 );
cmin = round(cmin);
cmax = round(cmax);
rmin = round(rmin);
rmax = round(rmax);
%计算目标的尺寸wsize:长与高
wsize(1) = abs(rmax - rmin);
wsize(2) = abs(cmax - cmin);
% create histogram
% translate to hsv
%把源图像转成hsv格式,取出需要的h通道,赋给huenorm
hsvimage = rgb2hsv(Image1);
% pull out the h
huenorm = hsvimage(:,:,1);
% scale to 0 to 255
%把h通道的数据大小从0-1调为0-255,并转化成uint8格式
hue = huenorm*255;
% set unit
您可能关注的文档
最近下载
- 2023年江苏省常州市中考语文试卷附参考答案.pdf VIP
- 四川专升本数学2025年真题 及答案 .pdf VIP
- 2026年寒假特色作业模板【可编辑 可打印】.pptx
- 任务一短期投资的核算.ppt VIP
- 生物必修二全套课件.ppt VIP
- 2023年江苏省常州市中考语文试卷.docx VIP
- 2025年江苏高考地理真题(解析版).docx
- 2026年教案课件-中华民族共同体概论-第1-9讲-混一南北与中华民族大统合-教案合集-新版.pdf VIP
- 新解读《GB_T 39329-2020增材制造 测试方法 标准测试件精度检验》.docx VIP
- 医疗器械部门职责与岗位划分指南.docx VIP
原创力文档

文档评论(0)