-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
43 lines (36 loc) · 1.28 KB
/
main.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
#include "webcam.h"
#include "webserver.h"
#include <QCoreApplication>
#include <QObject>
#include <QString>
#include <atomic>
#include <qdebug.h>
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
WebCam camera;
Webserver server(443);
std::atomic<bool> isCameraReady{false};
QObject::connect(&camera, &WebCam::cameraImageReady, &server,
&Webserver::onCameraImageAvailable);
QObject::connect(&camera, &WebCam::cameraReadyChanged,
[&isCameraReady](bool ready) {
qDebug() << "Camera ready - " << ready;
isCameraReady = ready;
});
QObject::connect(&server, &Webserver::commandReceived,
[&camera, &isCameraReady](const QString &command) {
qDebug() << "Command is: " << command;
if (command.contains("start")) {
camera.start();
}
if (command.contains("stop")) {
camera.stop();
}
if (command.contains("capture")) {
if (isCameraReady)
camera.capture();
}
});
camera.start();
return a.exec();
}