How to pass values between callback functions for video reading and extraction matlab Gui ?
Show older comments
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
1 Comment
Stephen23
on 25 Apr 2017
Question: "How to pass data between callbacks?"
Answer: exactly like the documentation explains:
The wiki also explains this:
http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
And some of the many threads on this forum that answer your question:
Answers (0)
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!