OpenCV四读取视频并显示(基于Python)
发布时间
阅读量:
阅读量
在OpenCV库中,用于读取和显示视频的头文件为highgui.hpp,而负责视频图像处理的头文件则为imgproc.hpp。以下为完整的代码实现,若希望使用个人图片进行测试,需将代码中指定的图片路径替换为自身图片的完整绝对路径。
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
int main()
{
namedWindow("Example2", WINDOW_AUTOSIZE);
VideoCapture cap;
cap.open("H:\ vs2017\ opencv_learning\ ConsoleApplication1\ video.mp4");
Mat frame;
while (1)
{
cap >> frame;
if (frame.empty()) break;
imshow("Exameple2",frame);
if (waitKey(33) >= 0) break;
}
return 0;
}
全部评论 (0)
还没有任何评论哟~
