亲测可用的代码,至于为什么把
VideoCapture cap();//写成全局变量,方便写其他C程序
VideoCapture capcap();
Mat frame;
Mat frame2;
写在全局变量,是为了在其他C文件里调用
只要在其他C文件加上
extern 语句就可以了。
#include<opencv2/opencv.hpp>
#include<thread>
using namespace cv;
VideoCapture cap();//写成全局变量,方便写其他C程序
VideoCapture capcap();
Mat frame;
Mat frame2;
int main()
{
if (!capcap.isOpened())return ;
if (!cap.isOpened())return ;
while (waitKey() != )
{
capcap >> frame2;
imshow("摄像头2", frame2);
cap >> frame;
imshow("摄像头1", frame);
}
return ;
}