资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
clear data disp(input video);avi = aviread(viplanedeparture.avi); video = avi.cdata; for a = 1:length(video)imagesc(videoa);axis image offdrawnow; end; disp(output video); tracking(video);function d = tracking(video) if ischar(video)% Load the video from an avi file.avi = aviread(video);pixels = double(cat(4,avi(1:2:end).cdata)/255;clear avi else% Compile the pixel data into a single arraypixels = double(cat(4,video1:2:end)/255;clear video end% Convert to RGB to GRAY SCALE image. nFrames = size(pixels,4); for f = 1:nFrames% F = getframe(gcf); % x,map=frame2im(F); % imwrite(x,fln.jpg,jpg); % endpixel(:,:,f) = (rgb2gray(pixels(:,:,:,f); end rows=240; cols=320; nrames=f; for l = 2:nrames d(:,:,l)=(abs(pixel(:,:,l)-pixel(:,:,l-1);k=d(:,:,l); % imagesc(k); % drawnow; % himage = imshow(d(:,:,l); % hfigure = figure; % impixelregionpanel(hfigure, himage);% datar=imageinfo(imagesc(d(:,:,l); % disp(datar);bw(:,:,l) = im2bw(k, .2);bw1=bwlabel(bw(:,:,l);imshow(bw(:,:,l)hold on% % for h=1:rows % for w=1:cols % % if(d(:,:,l)0.5)% disp(d(h,w,l);toplen = h;if (cou = 1)tpln=toplen;endcou=cou+1;breakendend enddisp(toplen);coun=1; for w=1:colsfor h=1:rowsif(bw(h,w,l)0.5)leftsi = w;if (coun = 1)lftln=leftsi;coun=coun+1;endbreakendend enddisp(leftsi); disp(lftln); % % drawnow; % % d = abs(pixel(:, :, l), pixel(:, :, l-1); % % disp(d);% s = regionprops(bw1, BoundingBox); % % centroids = cat(1, s.Centroid); % % % ang=s.Orientation; % % % plot(centroids(:,1), centroids(:,2), r*) % for r = 1 : length(s) % rectangle(Position,s(r).BoundingBox,EdgeColor,r); % % % plot(position,s(r).BoundingBox,faceregion,r); % end % % % disp(ang); % % imaqmontage(k);widh=leftsi-lftln; heig=toplen-tpln;widt=widh/2; disp(widt); heit=heig/2; with=lftln+widt; heth=tpln+heit; wth(l)=with; hth(l)=heth;disp(heit); disp(widh); disp(heig); rectangle(Position,lftln tpln widh heig,EdgeColor,r); disp(with); disp(heth); plot(with,heth, g+); drawnow; hold offend; % wh=square(abs(wth(2)-wth(nrames); % ht=square(abs(hth(2)-hth(nrames); % disp(wth(1 % distan=sqrt(wh+ht); % % disp(distan);
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号