How to pass values between callback functions for video reading and extraction matlab Gui ?

I am browsing video path using edit text with tag BrawsePath and want to extract frames of this video using ExtractVideo Button, but cant figure out way of doing this as I am new to Gui. here is the code I am working with: --------------------------------------------
function BrowseButton_Callback(hObject, eventdata, handles)
[filename pathname] = uigetfile({'*.mp4';'*.avi'},'File Selector');
video = [pathname filename];
if pathname ~= 0
set(handles.BrowsePath, 'String', video);
end
fid = fopen(fullfile(pathname, filename),'r');
RawData = textscan(fid, '%s', 'delimiter', '/n');
OfficeVideo = VideoReader(video);
hObject.OfficeVideo=OfficeVideo;
handles.fid=fid;
handles.video=video;
handles.RawData=RawData;
guidata(hObject, handles);
% --- Executes on button press in ExtractButton.
function ExtractButton_Callback(hObject, eventdata, handles)
opfolder = fullfile('C:','Users','Jay','Desktop','ExtractedFrames','Nature90');
%make directory and execute as indicated in op folder variable%
h = findobj('Tag','BrowseButton');
OfficeVid=h.OfficeVideo;
%OfficeVideo = VideoReader(vidfile);%
%read frame and store in output folder%
for ii = 1:OfficeVid.NumberOfFrames
img = read(OfficeVid,ii);
opBaseFileName = sprintf('%d.bmp',ii);
opFullFileName = fullfile(opfolder,opBaseFileName);
imwrite (img,opFullFileName,'bmp');
end

Answers (0)

Asked:

on 25 Apr 2017

Edited:

on 26 Apr 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!