get input from keyboard while displaying an avi with matlab

梦想与她 提交于 2020-01-17 09:12:06

问题


Hi all
I wrote a short program that displays an avi file. I need the program to get input from the keyboard while the movie is running (and not after it ends): this is my code:

figure('MenuBar','none')
set(gcf,'Color', 'white')
set(gca,'Color','white');
set(gca,'XColor','white');
set(gca,'YColor','white');
m=aviread('c:/t1.avi')
a=30:1:100;
b=100:-1:30;
c=[a b a b a b a b a b] %to run the movie back and forth
movie(m,c) %runs the movie

Thank you for any help
Ariel


回答1:


Maybe you can insert your video in an UIPanel (or another suitable GUI item) and use the KeyPressFcn callback. Have a look on this : Callback Sequencing and Interruption (I don't know if it can works but it's probably worth trying).




回答2:


As far as I know multi-threading or parallel processing capabilities in MATLAB are limited; however it appears as there are remedies. This article describes combining MATLAB and C++ code, with use of MEX files.

Now I have to admit that I have never tried this so I can't really claim that it would work in your case, but it would be a good place to start.




回答3:


Unless movie() has been designed to watch for input I think you will have to multithread, which from one of the other answers sounds a bit complicated.

You could play a short section of the video, then run come code to check for inputs and then play the next bit of the video. I'm not sure if you can count on things that the user types whilst the video plays going into the input buffer though.




回答4:


the solution is to use winopen('c:/filename.avi')

winopen('c:/filename.avi')
this command opens media player and runs following commands in the matlab script. it doesn't wait for the movie to end. it runs in the background.
thanks every one
ariel



来源:https://stackoverflow.com/questions/4733902/get-input-from-keyboard-while-displaying-an-avi-with-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!