Borrar filtros
Borrar filtros

How should I code for the max value of a slider?

1 visualización (últimos 30 días)
anahita
anahita el 14 de Jul. de 2013
In the GUI that I've created, at the first the user should load a video and after that he should be able to visualize any frame of this video. I want to put a slider that it's max should be the number of the frame of the loaded data, but I don't know how can I code for the max value(to be adapted with the number of the frame each time a file is loaded)... Someone told me to use
set(handles.your_slider, 'Max', N_frames);
set(handles.your_slider, 'SliderStep', [1/N_frames 1])
but it doesn't work...

Respuestas (1)

Image Analyst
Image Analyst el 14 de Jul. de 2013
Try putting this in the callback where you load the video and determine N_frames (say, the pushbutton callback where you ask the user to specify the input video file using uigetfile()):
set(handles.your_slider, 'Min', 1);
set(handles.your_slider, 'Max', N_frames);
set(handles.your_slider, 'SliderStep', [1/N_frames, 5/N_frames]);
set(handles.your_slider, 'Value', 1); % Initialize slider to first frame.
Then in the callback code for the slider:
sliderValue = int32(round(get(handles.your_slider, 'Value')));
thisFrame = read(yourVideoObject, sliderValue);
imshow(thisFrame);
Then when the user clicks the slider, the above code will execute and read in a frame and display it. Obviously some code is missing, such as that for uigetfile(), VideoReader(), etc. and I assume you know how to use the help to get that code into your code.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by