使用 matlab 显示 avi 时从键盘获取输入
大家好
我编写了一个显示 avi 文件的简短程序。我需要程序在电影运行时(而不是结束后)从键盘获取输入: 这是我的代码:
<块引用>图('菜单栏','无')
set(gcf,'颜色', '白色')
set(gca,'颜色','白色');
set(gca,'XColor','白色');
set(gca,'YColor','白色');
m=aviread('c:/t1.avi')
a=30:1:100;
b=100:-1:30;
c=[ababababab] %来回运行电影
movie(m,c) %运行电影
谢谢您的帮助
爱丽儿
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许您可以将视频插入 UIPanel(或其他合适的 GUI 项目)中并使用 KeyPressFcn 回调。
看看这个:回调排序和中断(我不知道不知道它是否有效,但可能值得尝试)。
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).
据我所知,MATLAB 中的多线程或并行处理能力是有限的;但似乎有补救措施。 本文介绍了如何使用 MEX 文件组合 MATLAB 和 C++ 代码。
现在我必须承认我从未尝试过这个,所以我不能真正声称它适用于你的情况,但这将是一个很好的起点。
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.
除非将 movie() 设计为监视输入,否则我认为您将必须使用多线程,从其他答案之一来看,这听起来有点复杂。
您可以播放视频的一小部分,然后运行代码来检查输入,然后播放视频的下一部分。我不确定您是否可以依靠用户在视频播放进入输入缓冲区时键入的内容。
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.
解决方案是使用 winopen('c:/filename.avi')
the solution is to use winopen('c:/filename.avi')