Ask Your Question
0

multiple webcam test [closed]

asked 2013-11-22 13:42:43 -0600

xiongtec gravatar image

updated 2013-11-22 15:07:10 -0600

So I have a usb logitech webcam and a built in laptop webcam. I am trying to start both the webcam at same time. I made a demo code below to test but cap2 object keep failing to open. Do any you guys have a suggestion. cap is the default which is the logitech webcam and cap2 is the built in web cap.

#include <iostream>
#include <opencv2\highgui\highgui.hpp>
#include <string>

int main(int arg, char * args[])
{
    cv::VideoCapture cap, cap2;
    cv::Mat mat1;
    cv::Mat mat2;

    cap.open(0);
    cap2.open(1);
    if(!cap.isOpened())
        return -1;
    if(!cap2.isOpened())
        return -2;

    cv::namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
    cv::namedWindow("MyVideo2",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo2"
    while(true)
    {
        cap.read(mat1);
        cap2.read(mat2);

        cv::imshow("MyVideo",mat1);

        cv::imshow("MyVideo2", mat2);
    }
    cap.release();
    cap2.release();
    return 0;
}
edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by StevenPuttemans
close date 2013-11-22 15:15:15.552358

Comments

And actually this is a duplicate of http://answers.opencv.org/question/24368/openning-multiple-webcam/ ... please stick to a single question! You can update the question itself using edit button.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-11-22 15:14:33 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-11-22 15:09:53 -0600

Actually I know that in windows it is not possible to create a single thread application that opens multiple webcams. You should try creating two seperate threads and open a camera in each thread for processing. Making two applications that grab from seperate cameras simultaneously is possible however I am not sure if this influences your data capture rate.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-11-22 13:42:43 -0600

Seen: 373 times

Last updated: Nov 22 '13