Effacer les filtres
Effacer les filtres

placing figure in current GUI in a particular location

3 vues (au cours des 30 derniers jours)
Raady
Raady le 25 Jan 2016
Commenté : Raady le 25 Jan 2016
I created an gui and named it as maingui i have a pushbutton, and in the call back function using uigetfile I browse the location of a video. Then in the same callbackfunction I call a function which reads the video and extract a frame from video, but I want to display the extracted frame on that GUI , how can I do that ?
function fntest_final()
MW.f = figure('Name','Project','Position', [1 1 700 1000]);
setappdata(0,'maingui',gcf);
MW.pb2 = uicontrol('Style', 'Pushbutton'.....
....
set(MW.pb2, 'Callback', {@loadbutton,MW});
end
function loadbutton(varargin)
MW = varargin{3};
reqfilename = uigetfile(....)
readvideofn %%i get error in navigating to this function
end
function readvideofn(reqfilename)
videoObject = VideoReader(reqfilename);
rgbImage = read(videoObject, 3200);
%%now I want to display this on the GUI in a particular fixed position
%%how ?
end
when I call the function it says Error while evaluating UIControl Callback

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Jan 2016
image() accepts x and y coordinates to display at. But I suspect that what you want is to generate an axes ahead of time, retrieve the axes handle in the routine, and pass the axes handle to image() as the first parameter.
  2 commentaires
Walter Roberson
Walter Roberson le 25 Jan 2016
At the top when you are creating MW, create MW.video_axes as the axes configured with the Position where you want the frame to be displayed.
function loadbutton(varargin)
MW = varargin{3};
[reqfilename, reqpath] = uigetfile(....);
thisfile = fullfile(reqpath, reqfilename);
readvideofn(thisfile, MW);
end
function readvideofn(reqfilename, MW)
videoObject = VideoReader(reqfilename);
rgbImage = [];
for K = 1 : 3200
if hasFrame(videoObject)
rgbImage = readFrame(videoObject);
else
break;
end
end
delete(videoObject);
dest_axes = MW.video_axes;
image(dest_axes, rgbImage);
axes(dest_axes, 'image');
end
You might notice that I replaced the read() with a loop. The read() method is deprecated and the replacement readFrame does not allow frames to be requested by number. I do not know why that is, but I suspect it might have to do with variable frame-rate videos.
Raady
Raady le 25 Jan 2016
thank you my friend it works ! generated axes ahead of time !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by