顶层函数camshift.docVIP

  • 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

文档评论(0)

1亿VIP精品文档

相关文档