问题描述
我想知道如何使用网络摄像头在MATLAB中录制视频.
I would like to know how I can record a video in MATLAB with my webcam.
推荐答案
注意: 由于某些旧功能已被取代,因此现已更新,可与新版本的MATLAB一起使用.并删除.
如果您已经知道如何从网络摄像头捕获单个图像,那么这应该只是缝合问题图像一起变成电影.您可以使用 VideoWriter
对象打开电影文件,然后然后使用 writeVideo
方法添加顺序图像.例如:
If you already know how to capture a single image from a webcam, then it should just be a matter of stitching the images together into a movie. You can use a VideoWriter
object to open a movie file and then add sequential images using the writeVideo
method. For example:
aviObject = VideoWriter('myVideo.avi'); % Create a new AVI file
for iImage = 1:100 % Capture 100 frames
% ...
% You would capture a single image I from your webcam here
% ...
writeVideo(aviObject, I); % Add the image to the AVI file
end
close(aviObject); % Close the AVI file
我只是使用了for循环作为简单示例,但您可能想使用 timer
,如果您想捕获图像并将其定期添加到AVI文件中.
I just used a for loop as a simple example, but you may want to use a timer
if you instead want to capture images and add them to the AVI file at regular time intervals.
这篇关于如何在MATLAB中录制来自网络摄像头的视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!