Borrar filtros
Borrar filtros

placing figure in current GUI in a particular location

3 visualizaciones (últimos 30 días)
Raady
Raady el 25 de En. de 2016
Comentada: Raady el 25 de En. de 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

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de En. de 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 comentarios
Walter Roberson
Walter Roberson el 25 de En. de 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 el 25 de En. de 2016
thank you my friend it works ! generated axes ahead of time !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by