I am trying to process a video by playing with its frames via the methods of OpenCV library and display these frames with imshow
method of opencv/highgui with no problem here.
But when it comes to display them in real-time with a Qt-gui app, I couldn't managed.
The program gets the path of the video from openfile dialog and starts to grap frames of the video within a while loop and process them. After process step, when I try to display these processed frames on a QLabel, the QLabel of gui-app doesn't display anything (along the length of the video) but only the last frame at the end of the video, nothing else. I tried to refresh/update the label for each frame but it didn't work.
Do I miss something to do? Or is there any more convenient method for it?
Necessary part of my code is below. Thanks in advance.
bool stop=false;
cv::VideoCapture capture("a.avi");
cv::Mat cur_frame;
while (!stop) {
//...
capture.read(cur_frame);
//process steps..
QImage img= QImage((const unsigned char*)(cur_frame.data),
cur_frame.cols,cur_frame.rows,
QImage::Format_RGB888);
ui->label->setPixmap(QPixmap::fromImage(img));
// resize the label to fit the image
ui->label->resize(ui->label->pixmap()->size());
//...
cv::waitkey(50);
}