打开视频文件,在LABEL显示,但命令窗口也出现视频,求去掉
在LABEL中播放视频,命令窗口也会自动播放,若其中cv::imshow 给去掉,则程序跑不动,请大家帮忙下,谢谢
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv2/opencv.hpp>
#include<QtWidgets>
#include <iostream>
#include <cv.h>
#include <highgui.h>
#include<QLabel>
//#include<camera.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//ui->pushButton_2->setEnabled(false);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString fileName= QFileDialog::getOpenFileName(this,tr("open frame"),".",
tr("image file(*.mp4 *.avi *.mkv )"));
cv::VideoCapture capture(fileName.toStdString());
bool stop(false);
double rate=capture.get(CV_CAP_PROP_FPS);
int delay= 1000/rate;
while(!stop)
{
if(27==cvWaitKey(33)) break;
// cv::namedWindow("Original video");
capture >> frame;
if(frame.empty()) break;
cvtColor(frame, frame, CV_BGR2RGB);
QImage img=QImage((const unsigned char*)(frame.data),frame.cols,frame.rows,frame.step,QImage::Format_RGB888);
ui->label_2->clear();
ui->label_2->setPixmap(QPixmap::fromImage(img));
ui->label_2->resize(ui->label_2->pixmap()->size());
cv::imshow("abd", frame);
}
capture.release();
}