-
Notifications
You must be signed in to change notification settings - Fork 3
/
Display.cpp
50 lines (40 loc) · 1.29 KB
/
Display.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
#include <QDebug>
#include <QSettings>
#include <QPainter>
#include "Display.h"
#include "ui_Display.h"
#include "VideoCapture.h"
#include "FaceTracker.h"
Display::Display(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Display)
{
ui->setupUi(this);
Q_ASSERT(connect( ui->captureControls->capture(), SIGNAL(gotFrame(QImage)), SLOT(showFrame(QImage))));
QSettings s("V2_Lab", "VisionThreadDemo");
ui->captureControls->load(s);
m_tracker = new FaceTracker;
// this also moves it to video thread
m_tracker->moveToThread(ui->captureControls->capture()->thread());
Q_ASSERT(connect(ui->captureControls->capture(), SIGNAL(gotFrame(QImage)), m_tracker, SLOT(detect(QImage))));
Q_ASSERT(connect(m_tracker, SIGNAL(facesDetected(QImage,QList<QRect>)), SLOT(showFaces(QImage,QList<QRect>))));
}
Display::~Display()
{
QSettings s("V2_Lab", "VisionThreadDemo");
ui->captureControls->save(s);
delete ui;
}
void Display::showFrame(const QImage &frame)
{
ui->videoLabel->setPixmap( QPixmap::fromImage(frame) );
}
void Display::showFaces(const QImage &frame, QList<QRect> faces)
{
QPixmap pix = QPixmap::fromImage(frame);
QPainter p(&pix);
p.setPen(Qt::white);
foreach(QRect rect, faces)
p.drawRect(rect);
ui->facesLabel->setPixmap( pix );
}