-
Notifications
You must be signed in to change notification settings - Fork 4
/
tensorflowthread.cpp
49 lines (40 loc) · 1.21 KB
/
tensorflowthread.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
#include "tensorflowthread.h"
void WorkerTF::setTf(Tensorflow *value)
{
tf = value;
}
void WorkerTF::setImgTF(const QImage &value)
{
imgTF = value;
}
void WorkerTF::work()
{
tf->run(imgTF);
emit results(tf->getKindNetwork(),tf->getResults(),tf->getConfidence(),tf->getBoxes(),tf->getInfTime());
emit finished();
}
TensorflowThread::TensorflowThread()
{
threadTF.setObjectName("Tensorflow thread");
worker.moveToThread(&threadTF);
QObject::connect(&worker, SIGNAL(results(int, QStringList, QList<double>, QList<QRectF>, double)), this, SLOT(propagateResults(int, QStringList, QList<double>, QList<QRectF>, double)));
QObject::connect(&worker, SIGNAL(finished()), &threadTF, SLOT(quit()));
QObject::connect(&threadTF, SIGNAL(started()), &worker, SLOT(work()));
}
void TensorflowThread::stop()
{
threadTF.exit();
}
void TensorflowThread::setTf(Tensorflow *value)
{
worker.setTf(value);
}
void TensorflowThread::run(QImage imgTF)
{
worker.setImgTF(imgTF);
threadTF.start();
}
void TensorflowThread::propagateResults(int network, QStringList captions, QList<double> confidences, QList<QRectF> boxes, double time)
{
emit results(network,captions,confidences,boxes,time);
}