MATLAB File Help: cv.VideoCapture Index
cv.VideoCapture

Class for video capturing from video files or cameras

The class provides an API for capturing video from cameras or for reading video files and image sequences.

Example

Here is how the class can be used:

cap = cv.VideoCapture(0);        % open the default camera
pause(3);                        % see note below
if ~cap.isOpened()               % check if we succeeded
    error('camera failed to initialized');
end
for t=1:30
   frame = cap.read();           % get a new frame from camera
   imshow(frame);
   pause(0.1);
end
% the camera will be deinitialized automatically in destructor
% when "cap" goes out of scope

Note

In some environments, there is a concurrency issue during camera initialization. To avoid unexpected crash, pause for a few seconds after the initialization of cv.VideoCapture object.

See also
Class Details
Superclasses handle
Sealed false
Construct on load false
Constructor Summary
VideoCapture Create a new VideoCapture object 
Property Summary
Brightness of the image (only for cameras). 
Contrast of the image (only for cameras). 
ConvertRGB Boolean flags indicating whether images should be converted to RGB. 
Exposure (only for cameras). 
FPS Frame rate. 
Format of the frames returned by cv.VideoCapture.retrieve. 
FourCC 4-character code of codec. 
FrameCount Number of frames in the video file. 
FrameHeight Height of the frames in the video stream. 
FrameWidth Width of the frames in the video stream. 
Gain of the image (only for cameras). 
Hue of the image (only for cameras). 
Mode Backend-specific value indicating the current capture mode. 
PosAviRatio Relative position of the video file: 
PosFrames 0-based index of the frame to be decoded/captured next. 
PosMsec Current position of the video file in milliseconds or video capture 
Rectification Currently unsupported 
Saturation of the image (only for cameras). 
id Object ID 
Method Summary
  addlistener Add listener for event. 
  delete Destructor 
  eq == (EQ) Test handle equality. 
  findobj Find objects matching specified conditions. 
  findprop Find property of MATLAB handle object. 
  ge >= (GE) Greater than or equal relation for handles. 
  get Returns the specified VideoCapture property 
  grab Grabs the next frame from video file or capturing device 
  gt > (GT) Greater than relation for handles. 
  isOpened Returns true if video capturing has been initialized already 
Sealed   isvalid Test handle validity. 
  le <= (LE) Less than or equal relation for handles. 
  lt < (LT) Less than relation for handles. 
  ne ~= (NE) Not equal relation for handles. 
  notify Notify listeners of event. 
  open Open video file or a capturing device for video capturing 
  read Grabs, decodes and returns the next video frame 
  release Closes video file or capturing device 
  retrieve Decodes and returns the grabbed video frame 
  set Sets a property in the VideoCapture