實戰深度學習OpenCV(二):讀取並播放本地或者攝像頭的視頻
阿新 • • 發佈:2018-12-01
spa cor enc waitkey pen return while apt size
一.讀取並播放的代碼如下:
#include "pch.h"
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace cv;
int main()
{
VideoCapture a;
a.open("C://Users//lenovo//Desktop//geeksong.mp4");
while (1)
{
Mat frame;
a >> frame;
imshow("讀取視頻", frame);
waitKey(600);
}
return 0;
}
二.獲取攝像頭裏的視頻,只需要將讀取視頻的路徑改為0就可以了:
#include "pch.h"
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
int main()
{
VideoCapture a;
a.open(0);
while (1)
{
Mat frame;
a >> frame;
imshow("讀取視頻", frame);
waitKey(600);
}
return 0;
}
實戰深度學習OpenCV(二):讀取並播放本地或者攝像頭的視頻