필터 지우기
필터 지우기

placing figure in current GUI in a particular location

조회 수: 3 (최근 30일)
Raady
Raady 2016년 1월 25일
댓글: Raady 2016년 1월 25일
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

채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 25일
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
Walter Roberson
Walter Roberson 2016년 1월 25일
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 2016년 1월 25일
thank you my friend it works ! generated axes ahead of time !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by