-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cpp
70 lines (61 loc) · 2.05 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
62
63
64
65
66
67
68
69
#include "MainWindow.h"
#include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//// This actually makes it a bit slower and can be removed
#ifdef USE_GPU_ACCEL
ui->graphicsView->setViewport(new QOpenGLWidget);
ui->graphicsView_2->setViewport(new QOpenGLWidget);
#endif
ui->graphicsView->setScene(new QGraphicsScene);
ui->graphicsView->scene()->addItem(&imgItem_1);
ui->graphicsView_2->setScene(new QGraphicsScene);
ui->graphicsView_2->scene()->addItem(&imgItem_2);
pipelineThrd_1 = new GstreamerThread(5000);
pipelineThrd_2 = new GstreamerThread(5001);
connect(pipelineThrd_1, &GstreamerThread::signalNewFrame, this ,&MainWindow::slotDisplayImage_1);
connect(pipelineThrd_2, &GstreamerThread::signalNewFrame, this ,&MainWindow::slotDisplayImage_2);
connect(pipelineThrd_1, &GstreamerThread::signalFPS, this ,[=](int num){
ui->labelFps->setText(QString::number(num)+" fps");
});
connect(pipelineThrd_2, &GstreamerThread::signalFPS, this ,[=](int num){
ui->labelFps_2->setText(QString::number(num)+" fps");
});
pipelineThrd_1->start();
pipelineThrd_2->start();
}
MainWindow::~MainWindow()
{
delete ui;
delete pipelineThrd_1;
delete pipelineThrd_2;
}
void MainWindow::slotDisplayImage_1(QImage im)
{
// qDebug() << "MainWindow::slotDisplayImage" << im;
imgItem_1.setPixmap(QPixmap::fromImage(im));
ui->graphicsView->fitInView(&imgItem_1);
ui->graphicsView->update();
}
void MainWindow::slotDisplayImage_2(QImage im)
{
// qDebug() << "MainWindow::slotDisplayImage" << im;
imgItem_2.setPixmap(QPixmap::fromImage(im));
ui->graphicsView_2->fitInView(&imgItem_2);
ui->graphicsView_2->update();
}
void MainWindow::on_btnStart_clicked()
{
qDebug() << "MainWindow::on_btnStart";
pipelineThrd_1->play();
pipelineThrd_2->play();
}
void MainWindow::on_btnStop_clicked()
{
qDebug() << "MainWindow::on_btnStop";
pipelineThrd_1->pause();
pipelineThrd_2->pause();
}