-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cpp
61 lines (57 loc) · 1.28 KB
/
MainWindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "QtOpenCVTools.h"
#include <QDebug>
#include <QTimer>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
cameraUse = false;
ui->setupUi(this);
QTimer *timer = new QTimer();
connect(timer, &QTimer::timeout, this, &MainWindow::updateImage);
timer->start(1);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
capture.open(0);
cameraUse = true;
// JfzStereoImgGet(1);
// Mat img = imread("E:\\我的坚果云\\头像\\异想家poi(310x310)无手-透明.png");
// if(img.empty())
// {
// qDebug() << "error";
// }
// else
// {
// // imshow("bridge", img);
// qDebug() << "ok";
// QImage image = MatToQImage(img);
// ui->label->setGeometry(10, 10, image.width(), image.height());
// ui->label->setPixmap(QPixmap::fromImage(image));
//// ui->label->setScaledContents(true);
// // waitKey();
// }
}
void MainWindow::updateImage()
{
if(cameraUse)
{
static uint aaa = 0;
qDebug() << aaa++;
Mat frame;
capture >> frame;
if(frame.data)
{
QImage image = MatToQImage(frame);
ui->label->setGeometry(10, 10, image.width(), image.height());
ui->label->setPixmap(QPixmap::fromImage(image));
this->update(); //发送刷新消息
}
}
}