-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.cpp
121 lines (96 loc) · 3.39 KB
/
camera.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "camera.h"
// #include "imagesettings.h"
// #include "metadatadialog.h"
// #include "videosettings.h"
#include <QAudioDevice>
#include <QAudioInput>
#include <QCameraDevice>
#include <QMediaDevices>
#include <QMediaFormat>
#include <QMediaMetaData>
#include <QMediaRecorder>
#include <QVideoWidget>
#include <QLineEdit>
#include <QMessageBox>
#include <QAction>
#include <QActionGroup>
#include <QImage>
#include <QKeyEvent>
#include <QPalette>
#include <QDir>
#include <QTimer>
#if QT_CONFIG(permissions)
#include <QPermission>
#endif
Camera::Camera(QObject *parent)
: QObject{parent}
{
init();
}
void Camera::init()
{
/*
#if QT_CONFIG(permissions)
// camera
QCameraPermission cameraPermission;
switch (qApp->checkPermission(cameraPermission)) {
case Qt::PermissionStatus::Undetermined:
qApp->requestPermission(cameraPermission, this, &Camera::init);
return;
case Qt::PermissionStatus::Denied:
qWarning("Camera permission is not granted!");
return;
case Qt::PermissionStatus::Granted:
break;
}
// microphone
QMicrophonePermission microphonePermission;
switch (qApp->checkPermission(microphonePermission)) {
case Qt::PermissionStatus::Undetermined:
qApp->requestPermission(microphonePermission, this, &Camera::init);
return;
case Qt::PermissionStatus::Denied:
qWarning("Microphone permission is not granted!");
return;
case Qt::PermissionStatus::Granted:
break;
}
#endif
m_audioInput.reset(new QAudioInput);
m_captureSession.setAudioInput(m_audioInput.get());
// Camera devices:
videoDevicesGroup = new QActionGroup(this);
videoDevicesGroup->setExclusive(true);
updateCameras();
connect(&m_devices, &QMediaDevices::videoInputsChanged, this, &Camera::updateCameras);
connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice);
connect(ui->captureWidget, &QTabWidget::currentChanged, this, &Camera::updateCaptureMode);
connect(ui->metaDataButton, &QPushButton::clicked, this, &Camera::showMetaDataDialog);
connect(ui->exposureCompensation, &QAbstractSlider::valueChanged, this,
&Camera::setExposureCompensation);
setCamera(QMediaDevices::defaultVideoInput()); */
}
void Camera::setCamera(const QCameraDevice &cameraDevice)
{
/*
m_camera.reset(new QCamera(cameraDevice));
m_captureSession.setCamera(m_camera.data());
connect(m_camera.data(), &QCamera::activeChanged, this, &Camera::updateCameraActive);
connect(m_camera.data(), &QCamera::errorOccurred, this, &Camera::displayCameraError);
if (!m_mediaRecorder) {
m_mediaRecorder.reset(new QMediaRecorder);
m_captureSession.setRecorder(m_mediaRecorder.data());
connect(m_mediaRecorder.data(), &QMediaRecorder::recorderStateChanged, this,
&Camera::updateRecorderState);
connect(m_mediaRecorder.data(), &QMediaRecorder::durationChanged, this,
&Camera::updateRecordTime);
connect(m_mediaRecorder.data(), &QMediaRecorder::errorChanged, this,
&Camera::displayRecorderError);
}
// m_captureSession.setVideoOutput(camera);
updateCameraActive(m_camera->isActive());
updateRecorderState(m_mediaRecorder->recorderState());
readyForCapture(m_imageCapture->isReadyForCapture());
updateCaptureMode();
m_camera->start(); */
}