function varargout = MyImg(varargin)
% MYIMG MATLAB code for MyImg.fig
% MYIMG, by itself, creates a new MYIMG or raises the existing
% singleton*.
%
% H = MYIMG returns the handle to a new MYIMG or the handle to
% the existing singleton*.
%
% MYIMG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MYIMG.M with the given input arguments.
%
% MYIMG('Property','Value',...) creates a new MYIMG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before MyImg_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to MyImg_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 MyImg
% Last Modified by GUIDE v2.5 12-Oct-2013 20:10:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @MyImg_OpeningFcn, ...
'gui_OutputFcn', @MyImg_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 MyImg is made visible.
function MyImg_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 MyImg (see VARARGIN)
set(handles.getImg,'enable','off');
set(handles.getVideo,'enable','off');
set(handles.getFm,'enable','off');
menu_open=get(handles.Open)
set(menu_open.Children(1),'enable','off');%注意:Children(1)对应的是Camera
set(menu_open.Children(2),'enable','off');
% Choose default command line output for MyImg
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes MyImg wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = MyImg_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 getImg.
function getImg_Callback(hObject, eventdata, handles)
% hObject handle to getImg (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
obj=handles.obj;
A=getsnapshot(obj);
imshow(A);
drawnow;
T = datestr(now,30);
imwrite(A,['G:\',T,'.jpg']);
% --- Executes on button press in getVideo.
function getVideo_Callback(hObject, eventdata, handles)
% hObject handle to getVideo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function getFm_Callback(hObject, eventdata, handles)
% hObject handle to getFm (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 getFm as text
% str2double(get(hObject,'String')) returns contents of getFm as a double
direct=handles.direct;
value=get(handles.getFm,'string');
value=str2num(value);
vidframes=VideoReader(direct{:});
len=vidframes.NumberOfFrames;
logth=floor(len/value)*value;
j=1;
for i=1:value:logth
frame=read(vidframes,i);
imwrite(frame,['G:\2','\',num2str(j),'.jpg']);
j=j+1;
end
% --- Executes during object creation, after setting all properties.
function getFm_CreateFcn(hObject, eventdata, handles)
% hObject handle to getFm (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --------------------------------------------------------------------
function Open_Callback(hObject, eventdata, handles)
% hObject handle to Open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
menu_open=get(handles.Open);
set(menu_open.Children(1),'enable','on');%注意:Children(1)对应的是Camera
set(menu_open.Children(2),'enable','on');
% --------------------------------------------------------------------
function Close_Callback(hObject, eventdata, handles)
% hObject handle to Close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close MyImg;
% --------------------------------------------------------------------
function Video_Callback(hObject, eventdata, handles)
% hObject handle to Video (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
uiwait(msgbox('请选择你的视频文件','选择视频'));
[fmname,fmpath]=uigetfile('*.avi','请选择视频文件');
if isempty(fmname)
errordlg('你未输入文件');
return;
end
fmname={fmname};fmpath={fmpath};
direct=strcat(fmpath,fmname);%得到文件的路径
set(handles.getFm,'enable','on');
handles.direct=direct;%用于传递数据
guidata(hObject,handles);%更新句柄数据
% --------------------------------------------------------------------
function Camera_Callback(hObject, eventdata, handles)
% hObject handle to Camera (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.getImg,'enable','on');
set(handles.getVideo,'enable','on');
obj=videoinput('winvideo',1,'RGB24_1280x720');
preview(obj);start(obj);
handles.obj=obj;
guidata(hObject,handles);
creat_img.rar_人脸检测
版权申诉
167 浏览量
2022-07-15
04:29:16
上传
评论
收藏 5KB RAR 举报
weixin_42653672
- 粉丝: 93
- 资源: 1万+