dtkmultimedia
DTK Multimedia module
载入中...
搜索中...
未找到
dcamera.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DCAMERA_H
6#define DCAMERA_H
7
8#if BUILD_Qt6
9#include <QCamera>
10#include <QCameraDevice>
11#include <QtMultimediaWidgets/QVideoWidget>
12#include <DMediaRecorder>
13#include <DImageCapture>
14#else
15#include <QCameraInfo>
16#endif
17
18#include "dtkmultimedia.h"
19
20DMULTIMEDIA_BEGIN_NAMESPACE
21
22class DCameraPrivate;
23class DMediaCaptureSession;
24class Q_MULTIMEDIA_EXPORT DCamera : public QCamera
25{
26 Q_OBJECT
27 Q_DECLARE_PRIVATE(DCamera)
28
29public:
30#ifdef BUILD_Qt6
31 enum State {
32 UnloadedState,
33 LoadedState,
34 ActiveState
35 };
36#endif
37
38 explicit DCamera(QCamera *parent = nullptr);
39#ifdef BUILD_Qt6
40 explicit DCamera(const QCameraDevice& cameraDevice, QObject *parent = nullptr);
41#else
42 explicit DCamera(const QCameraInfo &cameraInfo, QObject *parent = nullptr);
43#endif
44
45 ~DCamera();
46 void takeOne(const QString &location);
47 void takeVideo(const QString &location);
48 void start();
49 void stop();
52
53#ifdef BUILD_Qt6
54 void setViewfinder(QWidget *viewfinder);
55#else
56 void setViewfinder(QVideoWidget *viewfinder);
57#endif
58#ifdef BUILD_Qt6
59 void setActive(bool active) { m_isActive = active; };
60 void setstate(State newState);
61// void setRecorder(DMediaRecorder *recorder);
62// void setImageCapture(DImageCapture *imageCapture);
63#else
64 void setstate(QCamera::State newState);
65#endif
68 QStringList devList();
69 void openDev(const QString &sDevName);
70 void closeDev();
71 QByteArray yuvbuffer(uint &width, uint &height);
72 void resolutionSettings(const QSize &size);
73 QList<QSize> resolutions();
74 void setCameraCollectionFormat(const uint32_t &pixelformat);
75 void setFilter(const QString &filter);
76 void setExposure(const int &exposure);
78
79Q_SIGNALS:
80 void signalbuffer(uchar *yuv, uint width, uint height);
81#ifdef BUILD_Qt6
82 void stateChanged(State);
83#else
84 void stateChanged(State);
85#endif
86
87protected:
88 QScopedPointer<DCameraPrivate> d_ptr;
89
90#ifdef BUILD_Qt6
91 bool m_isActive;
92#endif
93};
94DMULTIMEDIA_END_NAMESPACE
95
96#endif
DCamera类提供相机操作功能.
Definition dcamera.h:25
QByteArray yuvbuffer(uint &width, uint &height)
获取相机当前的yuv(yu12)流数据.
void takeVideo(const QString &location)
相机录像,视频存放在指定位置.
QStringList devList()
获取相机的设备列表.
void setCameraCollectionFormat(const uint32_t &pixelformat)
设置相机输出的图片格式.
void setExposure(const int &exposure)
设置相机曝光度.
bool isWaylandEnv()
是否为Wayland系统环境.
QList< uint32_t > supportedViewfinderPixelFormats()
获取当前相机支持的图片数据格式.
void setViewfinder(QVideoWidget *viewfinder)
是否为Wayland系统环境.
void resolutionSettings(const QSize &size)
设置相机当前的分辨率.
QList< QSize > resolutions()
相机当前模式支持的分辨率.
DMediaCaptureSession * captureSession() const
获取相机的回话.
void start()
启动相机.
void setFilter(const QString &filter)
设置相机滤波格式.
void openDev(const QString &sDevName)
打开相机设备.
int checkCamera()
检测相机是否正常工作.
void takeOne(const QString &location)
相机拍照,图片存放在指定位置.
void stop()
停止相机.
void setstate(QCamera::State newState)
设置相机工作状态.
void closeDev()
关闭当前相机设备.
bool isFfmpegEnv()
是否为ffmpeg工作环境.
DMediaCaptureSession类提供相机连接回话相关信息.
Definition dmediacapturesession.h:29