⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imqacdemo03.m

📁 用MAtlab写的不错的运动目标检测的分析平台。 研究人员可借此学习在Matlab71上如何编写图形化界面的程序
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = imqacdemo03(varargin)
% IMQACDEMO03 M-file for imqacdemo03.fig
%      IMQACDEMO03, by itself, creates a new IMQACDEMO03 or raises the existing
%      singleton*.
%
%      H = IMQACDEMO03 returns the handle to a new IMQACDEMO03 or the
%      handle to
%      the existing singleton*.
%
%      IMQACDEMO03('CALLBACK',hObject,eventData,handles,...) calls the
%      local
%      function named CALLBACK in IMQACDEMO03.M with the given input arguments.
%
%      IMQACDEMO03('Property','Value',...) creates a new IMQACDEMO03 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before imqacdemo03_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to imqacdemo03_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

% Copyright 2002-2003 The MathWorks, Inc.

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

% Last Modified by GUIDE v2.5 23-Jul-2004 12:45:11

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @imqacdemo03_OpeningFcn, ...
                   'gui_OutputFcn',  @imqacdemo03_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 imqacdemo03 is made visible.
function imqacdemo03_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to imqacdemo03 (see VARARGIN)


handles.output = hObject;
Monitor_Mode(hObject, eventdata, handles);
S = imread('autumn.tif');
handles.S = S;
axes(handles.axes1);
subimage(S);
S2 = imread('autumn.tif');
axes(handles.axes2);
subimage(S2);
handles.S2 = S2;
guidata(hObject, handles);

% UIWAIT makes imqacdemo03 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = imqacdemo03_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on button press in pbStart.
function pbStart_Callback(hObject, eventdata, handles)
% hObject    handle to pbStart (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if isfield(handles,'outdata')
    handles = rmfield(handles,'outdata');
end
guidata(hObject, handles);
set(handles.pbStart,'enable','off');
set(handles.pbStop,'enable','on');

set(handles.pbStop,'UserData',0);

vid = videoinput('winvideo');
handles.vid = vid;
set(handles.vid,'FramesPerTrigger',1);
set(handles.vid,'TriggerRepeat',Inf);
triggerconfig(handles.vid, 'Manual');

guidata(hObject, handles);

start(handles.vid);
trigger(handles.vid);
y = (getdata(handles.vid,1,'uint8'));
cnt_move = 0;
cnt_unmove = 0;
cntsnap = 1;
while 1
    trigger(handles.vid);
    yprev = y;
    set(handles.editTime,'string',datestr(clock));
    if get(handles.pbStop,'UserData')
        break
    else
        y = (getdata(handles.vid,1,'uint8'));
        diff = abs(y-yprev);
        abs_img = mean(diff(:));
        set(handles.editAbs,'string',abs_img);
        axes(handles.axes1);subimage(y);
        axes(handles.axes2);subimage(diff);
        out = imaqmem;
        mem_left = out.FrameMemoryLimit - out.FrameMemoryUsed;
        set(handles.editMemLeft,'string',mem_left/10^6);
        set(handles.editMemLoad,'string',out.MemoryLoad);
        if abs_img > str2num(get(handles.editThresh,'string'));
            cnt_move = cnt_move + 1;
            set(handles.editObj,'string',cnt_move);
            if cnt_move >= str2num(get(handles.editSnapCnt,'string'));
                handles.outdata.image(:,:,:,cntsnap) = y;
                handles.outdata.time{cntsnap} = datestr(clock);
                cntsnap = cntsnap + 1;
                cnt_move = 0;
                set(handles.editSnap,'string',cntsnap-1);
            end
            cnt_unmove = 0;
        else
            cnt_unmove = cnt_unmove + 1;
            cnt_move = 0;
            set(handles.editObj,'string',cnt_move);
        end
        
        
    end
end


axes(handles.axes1);
cla;
subimage(handles.S);
axes(handles.axes2);
cla;
subimage(handles.S2);
delete(handles.vid);
clear handles.vid;
imaqreset;     
guidata(hObject, handles);


% --- Executes on button press in pbStop.
function pbStop_Callback(hObject, eventdata, handles)
% hObject    handle to pbStop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.pbStart,'enable','on');
set(handles.pbStop,'enable','off');

set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
guidata(hObject, handles);





function editAbs_Callback(hObject, eventdata, handles)
% hObject    handle to editAbs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editAbs as text
%        str2double(get(hObject,'String')) returns contents of editAbs as a double


% --- Executes during object creation, after setting all properties.
function editAbs_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editAbs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function editMemLeft_Callback(hObject, eventdata, handles)
% hObject    handle to editMemLeft (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editMemLeft as text
%        str2double(get(hObject,'String')) returns contents of editMemLeft as a double


% --- Executes during object creation, after setting all properties.
function editMemLeft_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editMemLeft (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function editMemLoad_Callback(hObject, eventdata, handles)
% hObject    handle to editMemLoad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editMemLoad as text
%        str2double(get(hObject,'String')) returns contents of editMemLoad as a double


% --- Executes during object creation, after setting all properties.
function editMemLoad_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editMemLoad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end





function editThresh_Callback(hObject, eventdata, handles)
% hObject    handle to editThresh (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editThresh as text
%        str2double(get(hObject,'String')) returns contents of editThresh as a double


% --- Executes during object creation, after setting all properties.
function editThresh_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editThresh (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -