Reputation: 849
I am trying to set a slider in MATLAB GUI to control video like move into some frames of the video. The 'obj' is the video file selected by the user. The following code was used to take the input video and show in an axes of the GUI.
global b
filename = get(handles.edit3, 'String');
if ~exist(filename, 'file')
warndlg( 'Text in edit box is not the name of a file');
return
end
try
obj = VideoReader(filename);
catch
warndlg( 'File named in edit box does not appear to be a usable movie file');
return
end
axes(handles.axes2)
handles.pushbutton5=0;
guidata(hObject,handles);
while ~(handles.pushbutton5)
if hasFrame(obj)
vidFrame = readFrame(obj);
obj;
image(vidFrame, 'Parent', handles.axes2);
set(axes, 'Visible', 'off');
pause(1/obj.FrameRate)
end
handles = guidata(hObject);
end
clear obj
The slider will provide "b" value while the user control the slider.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global b
b = get(handles.slider2,'Value');
Does anyone know how solve this problem so that the video can be controlled by the slider?
Upvotes: 2
Views: 811
Reputation: 1356
If you own the vision toolbox of matlab you can use this solution from matlab:
Upvotes: 1