Create a new VideoCapture object
cap = cv.VideoCapture(index)
cap = cv.VideoCapture(filename)
cap = cv.VideoCapture(..., 'API',apiPreference)
Input
- index id of the video capturing device to open. If there
is a single camera connected, just pass 0.
- filename name of the opened video file (eg.
video.avi
)
or image sequence (eg. img_%02d.jpg
, which will read
samples like img_00.jpg
, img_01.jpg
, img_02.jpg
, ...)
Options
- API preferred capture API to use. Can be used to enforce a
specific reader implementation if multiple are available:
e.g. 'FFMPEG' 'Images'. Available implementations:
- Any autodetect. This is the default.
- VfW platform native.
- V4L platform native.
- V4L2 platform native.
- FireWare IEEE 1394 drivers.
- FireWire IEEE 1394 drivers.
- IEEE1394 IEEE 1394 drivers.
- DC1394 IEEE 1394 drivers.
- CMU1394 IEEE 1394 drivers.
- QuickTime QuickTime.
- Unicap Unicap drivers.
- DirectShow DirectShow (via videoInput).
- PvAPI PvAPI, Prosilica GigE SDK.
- OpenNI OpenNI (for Kinect).
- OpenNIAsus OpenNI (for Asus Xtion).
- Android Android - not used.
- XIMEA XIMEA Camera API.
- AVFoundation AVFoundation framework for iOS
(OS X Lion will have the same API).
- Giganetix Smartek Giganetix GigEVisionSDK.
- MediaFoundation Microsoft Media Foundation
(via videoInput).
- WinRT Microsoft Windows Runtime using Media
Foundation.
- IntelPerC Intel Perceptual Computing SDK.
- OpenNI2 OpenNI2 (for Kinect).
- OpenNI2Asus OpenNI2 (for Asus Xtion and
Occipital Structure sensors).
- gPhoto2 gPhoto2 connection.
- GStreamer GStreamer.
- FFMPEG FFMPEG.
- Images OpenCV Image Sequence (e.g.
img_%02d.jpg
).
Creates a new video capture instance. With no argument, it
connects to the default camera device found in the system.
You can specify camera devices by index
, an integer value
starting from 0. You can also specify a filename
to open a
video file.
Example
To open camera 1 using the MS Media Foundation API:
cap = cv.VideoCapture(1, 'API','MediaFoundation')