class="markdown_views prism-atom-one-light">
视频读取
#include
#include
using namespace std;
using namespace cv;
int main()
{
VideoCapture capture("D:\1.mp4");
while (1)
{
Mat frame;
capture >> frame;
imshow("读取视频", frame);
waitKey(30);
}
return 0;
}
摄像头采集
#include
#include
using namespace std;
using namespace cv;
int main()
{
VideoCapture capture(0);
while (1)
{
Mat frame;
capture >> frame;
imshow("读取视频", frame);
waitKey(30);
}
return 0;
}
摄像头边采集边进行canny边缘检测
#include
#include
using namespace std;
using namespace cv;
int main()
{
VideoCapture capture(0);
while (1)
{
Mat frame,edges;
capture >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
blur(edges, edges, Size(7, 7));
Canny(edges, edges,0, 30, 3);
imshow("after_canny视频", edges);
waitKey(30);
}
return 0;
}