1

I am trying to create a dual camera array utilising ELP USB OV7725 based webcams: ELP 480P Mini Webcam USB2.0 OmniVision OV7725 Color CMOS Sensor VGA USB Camera Module (https://www.amazon.co.uk/gp/product/B01DK0FPYC/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1). Unfortunatelly I am not able to stream a video from more than a single ELP camera.

The source code is as follows:

#include <opencv2/opencv.hpp>
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/ximgproc/disparity_filter.hpp"
#include <iostream>
#include <string>

using namespace cv;
using namespace cv::ximgproc;
using namespace std;

int main()
{
    //initialize and allocate memory to load the video stream from camera 
    cv::VideoCapture camera0(0);
    cv::VideoCapture camera1(1);

    if( !camera0.isOpened() ) return 1;
    if( !camera1.isOpened() ) return 1;

    camera0.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    camera0.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
    camera1.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    camera1.set(CV_CAP_PROP_FRAME_HEIGHT, 480);

    while(true) {
        //grab and retrieve each frames of the video sequentially 
        cv::Mat3b frame0;
        cv::Mat3b frame1;

        camera0 >> frame0;
        camera1 >> frame1;

        // display results
        cv::imshow("Video0", frame0);
        cv::imshow("Video1", frame1);

        int c = cv::waitKey(20);
        //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27) 
        if(27 == char(c)) break;
    }

    return 0;
}

The output is as follows:

VIDIOC_STREAMON: No space left on device
init done 
opengl support available 
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/User/Data/Install/DevLibs/OpenCV/opencv/modules/highgui/src/window.cpp, line 289
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/User/Data/Install/DevLibs/OpenCV/opencv/modules/highgui/src/window.cpp:289: error: (-215) size.width>0 && size.height>0 in function imshow

Aborted (core dumped)

Using slightly modified source code I am able to simultaneously stream video from two Logitech C920 webcams + one of those OV7725.

#include <opencv2/opencv.hpp>
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/ximgproc/disparity_filter.hpp"
#include <iostream>
#include <string>

using namespace cv;
using namespace cv::ximgproc;
using namespace std;

int main()
{
    //initialize and allocate memory to load the video stream from camera 
    cv::VideoCapture camera0(4);
    cv::VideoCapture camera1(5);
    cv::VideoCapture camera2(0);

    if( !camera0.isOpened() ) return 1;
    if( !camera1.isOpened() ) return 1;
    if( !camera2.isOpened() ) return 1;

    camera0.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    camera0.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
    camera1.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    camera1.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
    camera2.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    camera2.set(CV_CAP_PROP_FRAME_HEIGHT, 480);

    while(true) {
        //grab and retrieve each frames of the video sequentially 
        cv::Mat3b frame0;
        cv::Mat3b frame1;
        cv::Mat3b frame2;

        camera0 >> frame0;
        camera1 >> frame1;
        camera2 >> frame2;

        // display results
        cv::imshow("Video0", frame0);
        cv::imshow("Video1", frame1);
        cv::imshow("Video2", frame2);

        //wait for 40 milliseconds

        int c = cv::waitKey(20);
        //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27) 
        if(27 == char(c)) break;
    }

    return 0;
}

Therefore I anticipate that it might be a driver problem of some sort. I tried to lower the resolution

camera0.set(CV_CAP_PROP_FRAME_WIDTH, 240);
camera0.set(CV_CAP_PROP_FRAME_HEIGHT, 240);    

or decrease the FPS:

camera0.set(CV_CAP_PROP_FPS, 15);
camera1.set(CV_CAP_PROP_FPS, 15);

However it did not help.

The camera seems to support the compressed mode (Motion-JPEG):

$ v4l2-ctl -d /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUYV 4:2:2

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'MJPG' (compressed)
        Name        : Motion-JPEG

the webcam seems to work in MJPG mode:

codecCode = cap.get(CV_CAP_PROP_FOURCC);

Any suggestions how to solve this issue?

bunicorn49
  • 11
  • 1
  • 2

0 Answers0