Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
log in
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no
registration required.
tour
help
I would like to know how I can record a video in MATLAB with my webcam.
m atlab
video
webcam
record
It is not clear to me from the question if you are trying to use a web cam to record your MATLAB session
(probably not, but I see people doing it). All of my videos are screen captures made and edited with Camtasia.
MatlabDoug Oct 29 '09 at 19:07
add a comment
5 Answers
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 convert an image file to a movie frame using
IM2FRAME, then you can use AVIFILE to create a video file from the frames. Here's how the code might
look:
aviObject = avifile('myVideo.avi'); % Create a new AVI file
for iFrame = 1:100
% Capture 100 frames
% ...
% You would capture a single image I from your webcam here
% ...
F = im2frame(I);
% Convert I to a movie frame
aviObject = addframe(aviObject,F); % Add the frame to the AVI file
end
aviObject = close(aviObject);
% Close the AVI file
I just used a for loop as a simple example, but you may want to use a MATLAB Timer Object if you
instead want to capture images and add them to the AVI file at regular time intervals.
edited Oct 28 '09 at 15:29
add a comment
http://stackoverflow.com/questions/1637589/how-do-i-record-video-from-a-webcam-in-matlab
1/3
11/17/2014
http://stackoverflow.com/questions/1637589/how-do-i-record-video-from-a-webcam-in-matlab
2/3
11/17/2014
add a comment
Here you can see great videos how to capture and process the images from webcam, so recording
shouldn't be hard:
http://blogs.mathworks.com/videos/2008/01/18/cool-feature-video-processing-demos/
answered Oct 30 '09 at 10:13
Gacek
3,799 4 26 52
add a comment
Not the answer you're looking for? Browse other questions tagged matlab video
webcam
http://stackoverflow.com/questions/1637589/how-do-i-record-video-from-a-webcam-in-matlab
3/3