Windowsの下opencvは同時に2つのカメラの採集プログラムを開きます


使用可能なコードを直接測定し、なぜ
VideoCapture cap(1);//      ,     C  
VideoCapture capcap(2);
Mat frame;
Mat frame2;

グローバル変数に書くのは、他のCファイルで呼び出すために他のCファイルにextern文を加えればいいのです.
#include
#include
using namespace cv;

VideoCapture cap(1);//      ,     C  
VideoCapture capcap(2);
Mat frame;
Mat frame2;

int main()
{


    if (!capcap.isOpened())return 0;
    if (!cap.isOpened())return 0;





    while (waitKey(30) != 27)
    {
        capcap >> frame2;
        imshow("   2", frame2);
        cap >> frame;
        imshow("   1", frame);
    }
    return 0;
}