Windows7+opencv+vs2015+c/c++实现四个摄像头同时工作


    VideoCapture cap;
    VideoCapture cap1;
    VideoCapture cap2;
    VideoCapture cap3;

    //if (!cap.isOpened()) 
    ///{
    //  cout << "摄像头未打开" << endl;
    //}
    //Mat M;
    //namedWindow("摄像头1", 1);
    cvWaitKey(300);

    Mat frame1,frame2,frame3,frame0;
    bool bStop = false;

    cap3.open(4);
    cap2.open(2);
    cap1.open(1);
    cap.open(0);
    //cap3.open(3);
    while (!bStop) {

        cap >> frame0;
        cap1 >> frame1;
        cap2 >> frame2;
        cap3 >> frame3;

1.基本介绍
视频读取本质上就是读取图像,因为视频是由一帧一帧图像组成的。1秒24帧基本就能流畅的读取视频了。
①读取视频有两种方法:


VideoCapture cap; 
cap.open(“1.avi”); 

或VideoCapture cap(“1.avi”);

②循环显示每一帧:


while(1) 
{ 
Mat frame; //定义Mat变量,用来存储每一帧 
cap>>frame; //读取当前帧方法一 
//cap.read(frame); //读取当前帧方法二 
imshow(“视频显示”, frame); //显示一帧画面 
waitKey(30); //延时30ms 
}

2.注意


cvWaitKey(0);暂停(只处理一帧图像)

处理连续多帧图像时不加

3.格式转换mat->IplImage

IplImage* pBinary0 = &IplImage(frame0);
深拷贝只要再加一次复制数据:  
IplImage *input0 = cvCloneImage(pBinary0);

4.usb控制器

效果图如下:

摄像头接口
使用的是四个相同红外+白光免驱摄像头,其中有摄像头插入HUB上,没有PCI扩展,
cap3.open(4);
cap2.open(2);
cap1.open(1);
cap.open(0);
最好按顺序从高到低排序

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值