OpenCV VideoCapture类
OpenCV VideoCapture类
视频捕获类,可以从视频文件、图像序列和摄像头捕获视频。
1. VideoCapture类构造函数:
创建 Video Capture 类的构造函数
功能:创建一个VideoCapture类的实例,如果传入对应的参数,可以直接打开视频文件或者要调用的摄像头。
函数:VideoCapture ()
说明: 当结束视频捕获时,调用cvReleaseCapture()释放CvCapture结构函数, 或在析构函数中自动调用
cvReleaseCapture()的Ptr<CvCapture> .
函数: VideoCapture (const String &filename, int apiPreference=CAP_ANY)
参数说明:
filename – 打开的视频文件名。
视频名 (eg. video.avi)
图像序列 (eg. img_%02d.jpg)
URL视频流 (eg. protocol://host:port/script_name?script_params|auth)
apiPreference – 当多种capture方式都可以使用时,指定一种方式(e.g. CAP_FFMPEG or CAP_IMAGES )
例程: cv::VideoCapture capture("C:/Users/DADA/DATA/gogo.avi"); // 从视频文件读取
函数: VideoCapture (int index, int apiPreference=CAP_ANY)
参数说明:
index - 要打开的视频捕获设备ID。打开默认相机定义ID为0;
apiPreference – 同上;
例程:VideoCapture (0);