Unsolved 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;
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;
} -
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.
-
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.