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. OpenCV displaying video in QLabel problem
Forum Update on Monday, May 27th 2025

OpenCV displaying video in QLabel problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 2.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.
  • mandruk1331M Offline
    mandruk1331M Offline
    mandruk1331
    wrote on last edited by
    #1

    I'm using OPencv for video capturing, I have the code below If I use it without a loop it shows one frame but when I put it in a loop it displays nothing what could be the problem?

    VideoCapture cap;
    cap.open(1);
    QVector<int> list_;
    if(cap.isOpened()){
    qDebug()<<"Opened";
    }

    Mat image;
    Mat frameM;
    for (;;) {
    cap >> image;
    //conversion from Mat to QImage
    Mat dest;
    cvtColor(image, dest,CV_BGR2RGB);
    QImage image1= QImage((uchar*) dest.data, dest.cols, dest.rows, dest.step,
    QImage::Format_RGB888);
    //show Qimage using QLabel
    ui->FirstDisplayLabel->setPixmap(QPixmap::fromImage(image1));
    ui->FirstDisplayLabel->show();
    //imshow("camera",image);
    //if (waitKey(30)>= 0) break;
    }

    Mandruk1331

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I suspect that when your "put it in a loop" you do it in an infinite loop that blocks Qt's own event loop thus blocking any GUI related activity.

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

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi

        Whenever u see

        for (;;)

        in a Qt program,
        it is a sure sign that something will not work as expected
        or be bad in some way.

        If loops takes too long, you will lag all of the application. It cannot draw or
        accept clicks.

        1 Reply Last reply
        1

        • Login

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