Opencv学习:多线程打开摄像头
程序员文章站
2022-07-05 10:14:24
...
Opencv学习笔记: C++ 多线程同时打开一个视频,或同时打开多个摄像头
AfxBeginThread函数
包含文件:#include<afxwin.h>
UINT read_video(LPVOID lpparam)
{
VideoCapture capture;
capture.open("C:/Users/x110276/Desktop/7.dav");
printf("thread1!!!\n");
if(!capture.isOpened())
{
printf("video open failed!\n");
return -1;
}
namedWindow("video",0);
cv::resizeWindow("video",640,480);
cv::Mat frame;
while(1)
{
capture>>frame;
if(frame.empty())
break;
imshow("video",frame);
cv::waitKey(1);
}
capture.release();
return 0;
}
UINT read_video2(LPVOID lpparam)
{
VideoCapture capture;
capture.open("C:/Users/x110276/Desktop/7.dav");
printf("thread2!!!\n");
if(!capture.isOpened())
{
printf("video open failed!\n");
return -1;
}
namedWindow("video2",0);
cv::resizeWindow("video2",640,480);
cv::Mat frame;
while(1)
{
capture>>frame;
if(frame.empty())
break;
imshow("video2",frame);
cv::waitKey(1);
}
capture.release();
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
CWinThread *pthread1, *pthread2;
pthread1 = AfxBeginThread(read_video,NULL);
pthread2 = AfxBeginThread(read_video2,NULL);
system("pause");
}
推荐阅读
-
python+opencv打开摄像头,保存视频、拍照功能的实现方法
-
python+opencv打开摄像头,保存视频、拍照功能的实现方法
-
Linux下利用Opencv打开笔记本摄像头问题
-
OpenCV学习笔记(一):使用opencv读取摄像头并实时显示
-
Opencv学习:多线程打开摄像头
-
荐 opencv进阶学习笔记1: 调用摄像头用法大全(打开摄像头,打开摄像头并实时不断截屏,读取视频并截图)
-
openCV学习笔记十七:摄像头中运动物体检测
-
Linux下利用Opencv打开笔记本摄像头问题
-
OpenCV视频入门操作,打开指定视频以及本地摄像头(C++)库函数图像识别追踪——VS2017-OpenCV4.0.1
-
VS2017+opencv(C++)学习笔记:调用外部摄像头、录像、拍照功能