4,445
社区成员
发帖
与我相关
我的任务
分享
#include "opencv2/opencv.hpp"
#include "iostream"
using namespace std;
using namespace cv;
int main()
{
VideoCapture camera1(1);
camera1.set(CAP_PROP_FRAME_WIDTH, 320);
camera1.set(CAP_PROP_FRAME_HEIGHT, 320);
VideoCapture camera0(0);
camera0.set(CAP_PROP_FRAME_WIDTH, 320);
camera0.set(CAP_PROP_FRAME_HEIGHT, 320);
if (!(camera1.isOpened() && camera0.isOpened())) { cout << "打开摄像头或读取失败!" << endl; return -1; }
Mat frame1,frame0;
namedWindow("Left");
namedWindow("Right");
while (1)
{
if (!(camera1.read(frame1) && camera0.read(frame0))) break;
imshow("Left", frame1);
imshow("Right", frame0);
if (waitKey(30) >= 0) break;
}
return 0;
}