Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Green output image from second Camera

Hi All. I have setup OpenCV 3.1.0 on my BeagleBone Black Rev C. All basic operations are working well. I have attached 3 cameras using USB hub to BBB. I have a simple OpenCV program that iterates through all the available programs and generate images in 3 different folders in OpenCV. I have verified that all cameras are available using lsusb command. Output in first image is fine with just weird lines on image. Output in second image is Green(Weird!). No Image is generated from third camera and i get the following output:

Not Working select timeout

Here is my code:

    int numberOfCameras = 3;
    for(int i=0; i<numberOfCameras; i++){
        cout << i<<endl;
        VideoCapture cap(i);
        if (cap.isOpened())
        {
            cout << "Camera working"<<endl;
        }
        else
        {
            cout<< "Not Working"<<endl;
        }
        cap.set(CV_CAP_PROP_FRAME_WIDTH,320);
        cap.set(CV_CAP_PROP_FRAME_HEIGHT,240);
        Mat frame;

       stringstream ss;
       ss << i;
       if(i==0)
       { 
            string fileName = "/electric1/" + ss.str() + ".jpg";
            Mat frame0;
            cap >> frame0;
            cout << fileName << endl;
            imwrite(fileName, frame0);
      }
      else if(i==1)
      {
            string fileName = "/gas1/" + ss.str() + ".jpg";
            Mat frame1;
            cap >> frame1;
            cout << fileName << endl;
            imwrite(fileName, frame1);
      }
      else if(i==2)
      {
             string fileName = "/water1/" + ss.str() + ".jpg";
             Mat frame2;
             cap >> frame2;
             cout << fileName << endl;
             imwrite(fileName, frame2);
      }
   }

Please let me know why i am getting this issue. Or any hint to right direction will be really great. Thanks