Hi guys,
I am using Qt and openCV to display some videos.
Everything works fine except that the video displays very fast! I thought it could be a problem with the frame rate definition in openCV, but it is not. Also tried to set a larger interval in the timer (QTimer), but none of this works.
Here is my code:
void MainWindow::on_btnLoad_clicked()
{
filename = ui->lnFile->text();
QByteArray ba = filename.toLocal8Bit();
string name = ba.data();
inputVideo = new VideoCapture(name.c_str());
inputVideo->set(CV_CAP_PROP_FPS, 27.5);
if (inputVideo->isOpened() == false){
ui->txtInfo->appendPlainText(“Problem loading file!”);
std::abort();
} else
ui->txtInfo->appendPlainText(“Ok!”);
timer = new QTimer(this);
cvWaitKey(100);
connect(timer, SIGNAL), this, SLOT));
timer->start(1);
}
void MainWindow::DisplayVideo(){
*inputVideo >> img;
QImage qImage((uchar*)img.data, img.cols, img.rows, img.step, QImage::Format_RGB888);
ui->lblVideo->setPixmap(QPixmap::fromImage(qImage));
}
Can anyone help me, please?
Thank you in advance,
↧