There is something wrong when I read 2+ cameras. [closed]

asked 2015-03-12 10:02:27 -0600

updated 2020-10-20 04:47:54 -0600

I have a project recently that I need to read more than 2 cameras using OpenCV. But I am facing a weird problem that I can't solve. When I execute my code step by step, it just OK, but when I run my project automatically, there is something wrong. Here is my code:

while (1)
{
////////////////////////////////////////////////////////////////////////////////
//When I execute the following part step by step, it is just OK
//But when I run the project automatically, there is someting wrong
    for (i=0; i<3; i++){
        cap = cvCaptureFromCAM(i);
        cvGrabFrame(cap);
        cam = cvRetrieveFrame(cap);
        cvCopy(cam, ImageBuffer[i]);
        cvReleaseCapture(&cap);
    }
///////////////////////////////////////////////////////////////////////////////
    cvGetCols(pairs, &part, 0, 640);                    
    cvCopy(ImageBuffer[0], &part);
    cvGetCols(pairs, &part, 640, 640*2);
    cvCopy(ImageBuffer[1], &part);
    cvGetCols(pairs, &part, 640*2, 640*3);
    cvCopy(ImageBuffer[2], &part);
    cvShowImage("Pairs", pairs);

    if(27==cvWaitKey(10))
        break;
}

When I run the project, the error is like that: image description

So, what is wrong with my code? Can anyone could solve the problem? Thanks In Advance!

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-20 04:46:19.862802

Comments

3

the 1st thing you should do is to get rid of the arcane c-api code. opencvc moved to c++ half a decade ago, and so should you.

also, chinese screenshots are not helpful.

berak gravatar imageberak ( 2015-03-12 10:09:36 -0600 )edit

Thank you for you suggestion! I will try to use the C++ code. I installed my VS2010 with Chinese language package, so the message box has some Chinese characters. I will try to reinstall my software.

lc7229469 gravatar imagelc7229469 ( 2015-03-12 21:45:19 -0600 )edit

Maybe (probably) it's the same problem as here: http://answers.opencv.org/question/31...

FooBar gravatar imageFooBar ( 2015-03-13 02:13:54 -0600 )edit

maybe you can just translate the error.

berak gravatar imageberak ( 2015-03-13 03:36:30 -0600 )edit