Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Displaying multiple OpenCV VideoCapture objects in QT

Displaying multiple OpenCV VideoCapture objects in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.4opencvopencv3.00c++
4 Posts 3 Posters 4.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SgtSherif
    wrote on last edited by
    #1

    Hey Guys, I'm capturing webcam streams from two raspberry pis and I'm trying to carry out some image processing on both streams. I have two Qlabels I'm trying to use to display the images from the pis. However, whilst one stream displays in real time, the other has a 4-5 second delay. The same result occurs if I try to display one stream on both Qlabel objects. Is this a threading issue? Can you guys please help out?

    VideoCapture capWebcam;
    VideoCapture EyeintheSky;
    Mat matEyeInTheSky;
    QImage qimgEyeInTheSky;
    Mat matOriginal;
    QImage qimgOriginal;
    
     MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
          ui->setupUi(this);
    
       capWebcam.open("http://192.168.0.102:8080/?action=stream?dummy=param.mjpg"); //from MJPG STreamer image processing
    
      EyeintheSky.open("http://192.168.0.100:8080/?action=stream?dummy=param.mjpg");
    
       if (capWebcam.isOpened() == false) {
          return;
          }
    
       if(EyeintheSky.isOpened() == false) {
        return;
         }
    }
    
    void MainWindow::processFrameAndUpdateGUI() {
    
    capWebcam.read(matOriginal);
    EyeintheSky.read(matEyeInTheSky);
    
    if(matOriginal.empty() == true) {
        qDebug() << "Empty Picture";
        return;
    }
    else {
       //  start of visual processing
    
        // Output Tri Track images to screen
        // map QImage to QLabel
        cvtColor(matOriginal,matOriginal,COLOR_BGR2RGB);
        QImage qimgOriginal((uchar*)matOriginal.data,matOriginal.cols,matOriginal.rows, matOriginal.step,QImage::Format_RGB888);
        ui->lblInputImage->setPixmap(QPixmap::fromImage(qimgOriginal));
    
        // Output Eye in the Sky to screen
        // map QImage to QLabel
        cvtColor(matEyeInTheSky, matEyeInTheSky, COLOR_BGR2RGB);
        QImage qimgEyeInTheSky((uchar*)matEyeInTheSky.data, matEyeInTheSky.cols, matEyeInTheSky.rows, matEyeInTheSky.step, QImage::Format_RGB888);
        ui->sky_input->setPixmap(QPixmap::fromImage(qimgEyeInTheSky));
    
        // Process IK code.
    
         }
    
     }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Partly it will come from your conversions and processing and the size of the image. Depending on the size of the image, it will also have an impact on the speed.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Partly it will come from your conversions and processing and the size of the image. Depending on the size of the image, it will also have an impact on the speed.

        S Offline
        S Offline
        SgtSherif
        wrote on last edited by
        #3

        @SGaist The image resolution is at 640 x 480. I've also tried streaming at 320 x 240 to test and the result is the same thing.

        1 Reply Last reply
        0
        • W Offline
          W Offline
          Wilk
          wrote on last edited by
          #4

          Hi
          Did you try to show vodeo capture only from the slow one? I think it might be usefull to test if the second camera slow only when image from both cameras is shown or it's always slow.

          Another suggection is to try to swap devices. It may be some kind of hardware problem.

          The last suggestion is to try to use QGraphicsView as soon as it might be just quicker than labels. However I don't think that the problem you described is in labels.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved