adjust camera shito for Qt6

This commit is contained in:
Arisotura
2022-10-01 20:16:52 +02:00
parent eca086ef95
commit 93dfcf8714
2 changed files with 112 additions and 23 deletions

View File

@ -23,17 +23,38 @@
#if QT_VERSION >= 0x060000
#include <QMediaDevices>
#include <QCameraDevice>
#include <QMediaCaptureSession>
#include <QVideoSink>
#else
#include <QCameraInfo>
#include <QAbstractVideoSurface>
#include <QVideoSurfaceFormat>
#endif
#include <QAbstractVideoSurface>
#include <QVideoSurfaceFormat>
#include <QMutex>
#include "types.h"
class CameraManager;
#if QT_VERSION >= 0x060000
class CameraFrameDumper : public QVideoSink
{
Q_OBJECT
public:
CameraFrameDumper(QObject* parent = nullptr);
public slots:
void present(const QVideoFrame& frame);
private:
CameraManager* cam;
};
#else
class CameraFrameDumper : public QAbstractVideoSurface
{
Q_OBJECT
@ -48,6 +69,9 @@ private:
CameraManager* cam;
};
#endif
class CameraManager : public QObject
{
Q_OBJECT
@ -88,6 +112,9 @@ private:
QCamera* camDevice;
CameraFrameDumper* camDumper;
#if QT_VERSION >= 0x060000
QMediaCaptureSession* camSession;
#endif
int frameWidth, frameHeight;
bool frameFormatYUV;