Important: Please read the Qt Code of Conduct -

OpenCV displaying video in QLabel problem

  • 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;;
    QVector<int> list_;

    Mat image;
    Mat frameM;
    for (;;) {
    cap >> image;
    //conversion from Mat to QImage
    Mat dest;
    cvtColor(image, dest,CV_BGR2RGB);
    QImage image1= QImage((uchar*), dest.cols, dest.rows, dest.step,
    //show Qimage using QLabel
    //if (waitKey(30)>= 0) break;

  • Lifetime Qt Champion


    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.

  • Lifetime Qt Champion


    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.

Log in to reply