| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2727 人关注过本帖
标题:求助:matlab视频处理问题
只看楼主 加入收藏
wxb13145
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-10-11
收藏
 问题点数:0 回复次数:0 
求助:matlab视频处理问题
各位朋友大家好,我遇见难题了,忘各位高手多加指教,我谢各位了,我的问题如下:
问题1: 我想用matlab做一个人体跟踪的程序,虽然能用仿真实现,但是仿真处理的是已经录制完的*.avi文件,而不能进行现场跟踪。现在摄像机已经连接好了,跟踪程序也写完了,但从一帧的获取到图像的处理完成花费时间太长,因此造成实时性很差,忘各位给予指点.
问题2;怎样才能实现帧的连续不断的获取,然后进行处理,我想到了用定时对象的回调来处理,但是不成功。具体设计是,在一个界面上放3个按钮,并写完了回调,功能分别时:帧的获取,人脸的提取,人脸的特征计算。想让这三个回调不再人交互情况下并行运行,怎么用定时对象进行处理,并且想问定时对象(timer)能让按钮的回调定时周期性的运行吗?下面是我的M文件:
function varargout = M_F_picturestation(varargin)
% M_F_PICTURESTATION M-file for M_F_picturestation.fig
%      M_F_PICTURESTATION, by itself, creates a new M_F_PICTURESTATION or raises the existing
%      singleton*.
%
%      H = M_F_PICTURESTATION returns the handle to a new M_F_PICTURESTATION or the handle to
%      the existing singleton*.
%
%      M_F_PICTURESTATION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in M_F_PICTURESTATION.M with the given input arguments.
%
%      M_F_PICTURESTATION('Property','Value',...) creates a new M_F_PICTURESTATION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before M_F_picturestation_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to M_F_picturestation_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help M_F_picturestation

% Last Modified by GUIDE v2.5 09-Oct-2008 10:28:45

% Begin initialization code - DO NOT EDIT
gui_Singleton = 0;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @M_F_picturestation_OpeningFcn, ...
                   'gui_OutputFcn',  @M_F_picturestation_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before M_F_picturestation is made visible.
function M_F_picturestation_OpeningFcn(hObject, eventdata, handles, varargin)%在界面打开时连接摄像机
ans=imaqhwinfo;
info = imaqhwinfo('winvideo');
dev_info = imaqhwinfo('winvideo',1);
vid = videoinput('winvideo');
vid_inf=get(vid);
set(vid,'LoggingMode','memory')
%set(vid,'LoggingMode','disk')
S_Soure=get(getselectedsource(vid));
set(vid,'FramesPerTrigger',10);
set(vid,'TriggerRepeat',inf);
triggerconfig(vid,'immediate')
%triggerconfig(vid, 'manual')
vid.FrameGrabInterval = 2;
vid_src = getselectedsource(vid);
set(vid_src,'Tag','motion detection setup');
axes(handles.axes5)
vidRes = get(vid, 'VideoResolution');
nBands = get(vid, 'NumberOfBands');
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
% Display the video data in your GUI.
close(h)
preview(vid, hImage);
camlight('headlight')
save myvid vid
save myh h

%创建定时器,让帧的获取隔一秒取一帧
t = timer( 'TimerFcn',@Collection_pushbutton_Callback,'Period',1,'ExecutionMode','FixedRate',);
% %启动定时器
start(t);

% 帧获取按钮的回调
function Collection_pushbutton_Callback(hObject, eventdata, handles)

[F map]=getframe(handles.axes5,[5 5 450 350]);
 delete(allchild(handles.axes1))
axes(handles.axes1)
hold on
imshow(F)
 handles.F=F;
 guidata(gcbo,handles);
pause(0.5)

%人脸提取按钮的回调
function TQ_pushbutton_Callback(hObject, eventdata, handles)

F=handles.F;
I=double(F);
[hue,s,v]=rgb2hsv(I);
%F=rgb2gray(F);
%F=dither(F);
cb =  0.148* I(:,:,1) - 0.291* I(:,:,2) + 0.439 * I(:,:,3) + 128;
cr =  0.439 * I(:,:,1) - 0.368 * I(:,:,2) -0.071 * I(:,:,3) + 128;
[w h]=size(I(:,:,1));
for i=1:w
    for j=1:h            
        if  135<=cr(i,j) & cr(i,j)<=170 & 130<=cb(i,j) & cb(i,j)<=190 & 0.0<=hue(i,j) & hue(i,j)<=0.3   
           segment(i,j)=1;            
        else      
            segment(i,j)=0;   
        end   
    end
end
toc

handles.segment=segment;
guidata(gcbo,handles)

% 人脸特征计算的回调
function CL_pushbutton_Callback(hObject, eventdata, handles)

segment=handles.segment;
S=medfilt2(segment);%中值滤波
   SM=strel('disk',5);
   S=imopen(S,SM);
       S=imclose(S,SM);%闭运算
  S=imfill(S,'holes'); % 填孔处理
fe=imerode(S,ones(8,7)); %腐蚀操作
fo=imopen(S,ones(8,7)); %开启操作
S=imreconstruct(fe,S);
[L,num]=bwlabel(S,8);
handles.L=L;

for i=1:num
  [r c]=find(L==i);   
   x_min=min(r);
   x_max=max(r);
   y_min=min(c);
   y_max=max(c);
   H=x_max-x_min;
   W=y_max-y_min;
   Area=H*W;
   Div=H/W;
   if (H>W)&&(Area>6000)&&(1.2<Div<2.1)      
       if Div>1.5
        x_max=x_max-H/4;
        rbar=mean(r)-H/7;
       else
        x_max=max(r);
        rbar=mean(r)
        end
        y_min=min(c)+5;
        y_max=max(c)+10;
        cbar=mean(c);
       axis(:,2)=[x_min x_min x_max x_max x_min];
       axis(:,1)=[y_min y_max y_max y_min y_min];
       axes(handles.axes1)
       hold on
       h1=plot(axis(:,1),axis(:,2),'linewidth',2,'color',[0.0 1.0 0.502]);
       axes(handles.axes1)
       hold on
       h2=plot(cbar,rbar,'marker','+','markeredgecolor','g','markersize',10);
   end
end



请教怎么用定时功能让这三个回调交替执行
搜索更多相关主题的帖子: matlab 视频 
2008-10-11 14:33
快速回复:求助:matlab视频处理问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018957 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved