使用intel Xe显卡处理图像
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

63 lines
1.3 KiB

#include "mainwindow.h"
#include "./ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
cap = new VideoCapture();
onCap = false;
vt = new QTimer(this);
// vt->start(20);
QObject::connect(vt,SIGNAL(timeout()),this,SLOT(showImage()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
if(onCap){
vt->stop();
onCap = false;
}
else{
bool isnum;
int z = ui->lineEdit->text().toUInt(&isnum);
if(isnum){
cap->open(z);
}
else{
cap->open(ui->lineEdit->text().toStdString());
}
vt->start(20);
onCap = true;
}
}
void MainWindow::showImage(){
if(NULL!=cap){
if(cap->read(image)){
// image =
// cv::edgePreservingFilter(image,image);
cv::cvtColor(image,image,cv::COLOR_RGB2BGR);
ui->label->setPixmap(QPixmap::fromImage(QImage(image.data,image.cols,image.rows,QImage::Format_RGB888)));
}
}
}
void MainWindow::on_pushButton_2_clicked()
{
QFile f("img.bin");
f.open(QIODevice::ReadWrite);
QDataStream streamout(&f);
streamout.writeBytes((char*)image.data,image.rows*image.cols*3);
f.close();
}