VideoCapture类
videocapture类可以使用户从视频文件、图像序列、相机中播放视频到显示屏中,它有四种重载形式:
CV_WRAP VideoCapture();
CV_WRAP VideoCapture(const String& filename);
CV_WRAP VideoCapture(const String& filename, int apiPreference);
CV_WRAP VideoCapture(int index);
>> 操作符
OpenCV中>>用于读取视频的下一帧
virtual VideoCapture& operator >> (CV_OUT Mat& image);
例如:
cap >> frame;
示例
#include<opencv2\opencv.hpp>
using namespace cv;
void main()
{
VideoCapture cap;
cap.open(0);
while (1)
{
Mat frame;
cap >> frame;
imshow("读取视频", frame);
waitKey(20); //waitKey()中的参数可以用来控制帧率,20ms表示帧率等于1/(20ms)=50fps
}
}