-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
51 lines (44 loc) · 1.06 KB
/
Copy pathmainwindow.cpp
File metadata and controls
51 lines (44 loc) · 1.06 KB
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
using namespace cv;
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qRegisterMetaType<cv::Mat>("cv::Mat");
c = 0;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::closeEvent(QCloseEvent *ev)
{
if(c)
{
c->stopCam();
disconnect(c, SIGNAL(sendFrame(cv::Mat)), this, SLOT(getFrame(cv::Mat)));
c->deleteLater();
}
}
void MainWindow::on_actionOpen_Camera_triggered()
{
if(ui->actionOpen_Camera->isChecked())
{
c = new camera();
connect(c, SIGNAL(sendFrame(cv::Mat)), this, SLOT(getFrame(cv::Mat)));
c->start();
}
else
{
c->stopCam();
}
}
void MainWindow::getFrame(cv::Mat dst)
{
//cv::imshow("ya", dst);
cv::resize(dst, dst, cv::Size(ui->loadImage->width(), ui->loadImage->height()));
ui->loadImage->setPixmap(QPixmap::fromImage(QImage(dst.data, dst.cols, dst.rows, dst.step, QImage::Format_RGB888).rgbSwapped()));
}