Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
anahita
anahita il 14 Lug 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...

Risposte (1)

Image Analyst
Image Analyst il 14 Lug 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.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by