Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I could record video from webcam (for video processing in matlab 2013 and before) by using following code.

But, since in matlab 2015 some functions have changed and there is no backward compatibility, I can't do that again! For example, avifile() function has been replaced by writeVideo().

Please help me to solve the problem.

What I have tried:

C++
clear all; %% clear all privious variables
clc;
%warning('off','all'); %.... diable warining msg ...;
vid = videoinput('winvideo',1, 'YUY2_320x240');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb');
% vid.FrameRate =30;
vid.FrameGrabInterval = 1;  % distance between captured frames 
start(vid)

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
  % ...

  I=getsnapshot(vid);
%imshow(I);
  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
stop(vid);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900