hi there, i am having some dificulties with my GUI, i made a GUI to record video from my webcam and evrything is going well but there is a problem when i play the video, the video goes too fast. how can i get i normal video?
1 回表示 (過去 30 日間)
古いコメントを表示
jorge alejandro guerrero díaz
2017 年 6 月 5 日
コメント済み: jorge alejandro guerrero díaz
2017 年 6 月 7 日
function varargout = untitled2(varargin)
% UNTITLED2 MATLAB code for untitled2.fig
% UNTITLED2, by itself, creates a new UNTITLED2 or raises the existing
% singleton*.
%
% H = UNTITLED2 returns the handle to a new UNTITLED2 or the handle to
% the existing singleton*.
%
% UNTITLED2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED2.M with the given input arguments.
%
% UNTITLED2('Property','Value',...) creates a new UNTITLED2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled2_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 untitled2
% Last Modified by GUIDE v2.5 02-Jun-2017 18:42:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled2_OpeningFcn, ...
'gui_OutputFcn', @untitled2_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 untitled2 is made visible.
function untitled2_OpeningFcn(hObject, ~, 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 untitled2 (see VARARGIN)
% Choose default command line output for untitled2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled2_OutputFcn(~, ~, 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 configuracion.
function configuracion_Callback(~, ~, handles)
% hObject handle to configuracion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global IA DeviceID Format
IAHI=imaqhwinfo;
IA=(IAHI.InstalledAdaptors);
D=menu('Seleccione dispositivos de Entrada de video instalado:',IA);
if isempty(IA)||D==0
msgbox({'no hay ningun adaptador de entrada de video instalado!',...
'O',...
'Intente de Nuevo y seleccione el adaptador apropiado.'})
return
end
IA=char(IA);
IA=IA(D,:);
IA(IA==' ')=[];
x=imaqhwinfo(IA);
try
DeviceID=menu('seleccione ID de Dispositivo',x.DeviceIDs);
F=x.DeviceInfo(DeviceID).SupportedFormats;
nF=menu('seleccione el Formato',F);
Format=F{nF};
catch e
warndlg({'intente con otro dispositivo ';...
'No esta instalado el dispositivo de enetrada de video'})
return
end
set(handles.v_previa, 'enable', 'on');
set(handles.control, 'enable', 'off');
% --- Executes on button press in v_previa.
function v_previa_Callback(hObject, eventdata, handles)
% hObject handle to v_previa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global IA DeviceID Format VidObj cam
try
VidObj= videoinput(IA, DeviceID, Format);
handles.VidObj=VidObj;
vidRes = get(handles.VidObj, 'VideoResolution');
nBands = get(handles.VidObj, 'NumberOfBands');
set(handles.PRW,'Visible','off')
axes(handles.PRW)
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
preview(handles.VidObj, hImage)
catch E
msgbox({'configure corectamente la camara!',' ',E.message},'CAM INFO')
end
guidata(hObject, handles);
set(handles.control, 'enable','on');
cam=0;
% --- Executes on button press in control.
function control_Callback(~, ~, handles)
% hObject handle to control (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global VidObj cam vid aviobj
if cam == 0
[na,ca]=uiputfile({'*.avi'});
% nom = datestr(now, 'local');
% nombre = strcat(nom, '.avi');
vid = VidObj;
aviobj = VideoWriter(fullfile(ca,na));
vid.LoggingMode = 'disk&memory';
vid.DiskLogger = aviobj;
vid.TriggerRepeat = 300;
start(vid);
set(handles.control, 'String', 'PARAR');
set(handles.control, 'ForegroundColor','black');
set(handles.configuracion, 'enable', 'off');
set(handles.v_previa, 'enable', 'off');
cam = 1;
else
stop(vid);
% aviobj =
close(vid.DiskLogger);
delete(vid);
clear vid;
clear aviobj;
set(handles.control, 'String', 'GRABAR');
set(handles.control,'ForegroundColor', 'red');
set(handles.configuracion, 'enable','on');
set(handles.v_previa, 'enable', 'on');
cam = 0;
end
% --- Executes on button press in salir.
function salir_Callback(~, ~, ~)
% hObject handle to salir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear all
close all
2 件のコメント
Walter Roberson
2017 年 6 月 5 日
"clear all" should never appear in a function. "close all" is dubious too.
採用された回答
Walter Roberson
2017 年 6 月 6 日
Set the FrameRate property of aviobj to an appropriate value. The default is 30 (frames per second)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で National Instruments Frame Grabbers についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!