Play Video in MATLAB GUI with other Objects

Hi, all. I'm starting an experiment where I need to have a video window, as well as a number of text boxes and buttons in a single GUI window. Is this possible? Does anyone have any example code or suggestions on how I might be able to embed the video into the GUI and control it?
Thank you kindly.
Bill

 채택된 답변

Chaowei Chen
Chaowei Chen 2011년 8월 27일

0 개 추천

function main(var_3D)
if nargin<1, var_3D=randn(100,100,100);end
[R,C,Frame]=size(var_3D);
h_play=uicontrol('style','pushbutton','callback',@play_var,'string','play');
h_text1=uicontrol('style','edit','string','edit1','position',[200 20 80 20]);
h_text2=uicontrol('style','edit','string','edit2','position',[300 20 80 20]);
function play_var(hObject,events)
for f=1:Frame
imshow(var_3D(:,:,f));
title(['frame ' int2str(f)]);
drawnow;
end
end
end

댓글 수: 2

save above as a *.m file. Executing it should do your quest.
Bill
Bill 2011년 8월 27일
Chaowei, will this also play audio from the video files I'll be using? I have .avi files with audio, so I'll need the audio to play along with the video.
Thanks.

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

추가 답변 (3개)

Chaowei Chen
Chaowei Chen 2011년 8월 27일

0 개 추천

function main
vid = videoinput('winvideo', 1);
figure;
h_play=uicontrol('style','pushbutton','callback',@play_vid,'string','play','position',[200 20 80 20]);
h_stop=uicontrol('style','pushbutton','callback',@stop_vid,'string','stop','position',[300 20 80 20]);
h_img=image;
%%
function play_vid(hObject,events), preview(vid,h_img), end
function stop_vid(hObject,events), stoppreview(vid), end
end

댓글 수: 3

This unpolished code may do your work if you plug a USB webcam.
Also, http://www.mathworks.com/help/toolbox/imaq/f11-74309.html
may help.
Bill
Bill 2011년 8월 27일
This seems to open my webcam. Any way you can provide me with code for importing my own video and playing it?
Bill
Bill 2011년 8월 27일
Sorry, I missed your last comment. I should clarify. I don't need to record audio and video from a subject. I already have video files with audio saved and will need to play them depending on the trial the participant is on. Is there a function where I can import one of my .avi files into the workspace and then play it?

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

Chaowei Chen
Chaowei Chen 2011년 8월 27일

0 개 추천

function main
[f,p]=uigetfile('*.avi');cd(p)
h_play=uicontrol('style','pushbutton','callback',@play_vid,'string','play','position',[200 20 80 20]);
function play_vid(hObject,events), winopen(f); end
end

댓글 수: 1

This won't put the video window in the GUI. Maybe somebody can help.

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

카테고리

태그

질문:

2011년 8월 27일

답변:

2016년 4월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by