playtree
2008-04-16, 20:09
请教在matlab中,如何实现在暂停播放视频后,继续播放视频?
暂停是通过pause函数来实现的,那请问实现继续播放更如何实现呢?
请高手指点。
谢谢
playtree
2008-04-17, 19:23
我想通过循环播放视频帧的形式实现播放、暂停、继续的功能
现在播放、暂停的功能实现了
播放是通过按第一个按钮采用循环播放的步骤实现:
mov=aviread('1.avi');
lm=size(mov,2);%影片的长度
tmp=1;
for i=tmp : lm %逐帧播放视频文件
ff=mov(i);%得到视频文件的第i帧
movie(ff,1,30);%播放视频文件的第i帧
nmf=i;%存放当前的视频帧
end
暂停是通过第二个按钮实现的:
pause;
现在的问题是第三个按钮实现继续的时候,出来问题:
lm=size(mov,2);%影片的长度
%从暂停之后的下一帧开始播放
tmp=nmf+1;%暂停之后的下一帧
for i=tmp : lm %逐帧播放视频文件
ff=mov(i);%得到视频文件的第i帧
movie(ff,1,30);%播放视频文件的第i帧
nmf=i;%存放当前的视频帧
end
按下去之后,没有反应。
请问是那句代码与问题?
playtree
2008-04-17, 19:28
此时还有一个问题,就是在暂停之后,再次按第一个按钮实现正常播放时,也没有反应。
playtree
2008-04-17, 19:59
也就是怎样取消暂停呢?可以通过按钮执行什么命令实现吗?
我试过按下任意键可以继续播放,
那在gui界面该如何实现继续播放呢?
monkeygk
2009-01-08, 01:04
這是可以啟動跟停止的
我把原碼全都貼上了
你試試看囉~
function varargout = myCameraGUI(varargin)
% MYCAMERAGUI M-file for myCameraGUI.fig
% MYCAMERAGUI, by itself, creates a new MYCAMERAGUI or raises the existing
% singleton*.
%
% H = MYCAMERAGUI returns the handle to a new MYCAMERAGUI or the handle to
% the existing singleton*.
%
% MYCAMERAGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MYCAMERAGUI.M with the given input arguments.
%
% MYCAMERAGUI('Property','Value',...) creates a new MYCAMERAGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before myCameraGUI_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to myCameraGUI_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 myCameraGUI
% Last Modified by GUIDE v2.5 14-Apr-2004 10:30:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @myCameraGUI_OpeningFcn, ...
'gui_OutputFcn', @myCameraGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 myCameraGUI is made visible.
function myCameraGUI_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 myCameraGUI (see VARARGIN)
% Choose default command line output for myCameraGUI
handles.output = hObject;
% Create video object
% Putting the object into manual trigger mode and then
% starting the object will make GETSNAPSHOT return faster
% since the connection to the camera will already have
% been established.
handles.video = videoinput('winvideo', 1);
set(handles.video,'TimerPeriod', 0.05, ...
'TimerFcn',['if(~isempty(gco)),'...
'handles=guidata(gcf);'... % Update handles
'image(getsnapshot(handles.video));'... % Get picture using GETSNAPSHOT and put it into axes using IMAGE
'set(handles.cameraAxes,''ytick'',[],''xtick'',[]),'... % Remove tickmarks and labels that are inserted when using IMAGE
'else '...
'delete(imaqfind);'... % Clean up - delete any image acquisition objects
'end']);
triggerconfig(handles.video,'manual');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes myCameraGUI wait for user response (see UIRESUME)
uiwait(handles.myCameraGUI);
% --- Outputs from this function are returned to the command line.
function varargout = myCameraGUI_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
handles.output = hObject;
varargout{1} = handles.output;
% --- Executes on button press in startStopCamera.
function startStopCamera_Callback(hObject, eventdata, handles)
% hObject handle to startStopCamera (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Start/Stop Camera
if strcmp(get(handles.startStopCamera,'String'),'Start Camera')
% Camera is off. Change button string and start camera.
set(handles.startStopCamera,'String','Stop Camera')
start(handles.video)
else
% Camera is on. Stop camera and change button string.
set(handles.startStopCamera,'String','Start Camera')
stop(handles.video)
end
vBulletin® v3.8.3,版权所有 ©2000-2025,Jelsoft Enterprises Ltd.