Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
androidcamera_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// Copyright (C) 2016 Ruslan Baratov
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef ANDROIDCAMERA_H
6#define ANDROIDCAMERA_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qobject.h>
20#include <qsize.h>
21#include <qrect.h>
22#include <QtMultimedia/qcamera.h>
23#include <QtCore/qjniobject.h>
24#include <private/qcameradevice_p.h>
25
27
28class QThread;
29
33
34class AndroidCamera : public QObject
35{
37public:
43
44 enum ImageFormat { // same values as in android.graphics.ImageFormat Java class
46 RGB565 = 4,
47 NV16 = 16,
48 NV21 = 17,
49 YUY2 = 20,
50 JPEG = 256,
51 YV12 = 842094169
52 };
53 Q_ENUM(ImageFormat)
54
55 // http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupportedPreviewFpsRange%28%29
56 // "The values are multiplied by 1000 and represented in integers"
57 struct FpsRange {
58 int min;
59 int max;
60
61 FpsRange(): min(0), max(0) {}
62
63 qreal getMinReal() const { return min / 1000.0; }
64 qreal getMaxReal() const { return max / 1000.0; }
65
67 {
69 range.min = static_cast<int>(min * 1000.0);
70 range.max = static_cast<int>(max * 1000.0);
71 return range;
72 }
73 };
74
76
77 static AndroidCamera *open(int cameraId);
78
79 int cameraId() const;
80
81 bool lock();
82 bool unlock();
83 bool reconnect();
84 void release();
85
88
90 QList<QSize> getSupportedPreviewSizes();
91
92 QList<FpsRange> getSupportedPreviewFpsRange();
93
94 FpsRange getPreviewFpsRange();
95 void setPreviewFpsRange(FpsRange);
96
97 ImageFormat getPreviewFormat();
98 void setPreviewFormat(ImageFormat fmt);
99 QList<ImageFormat> getSupportedPreviewFormats();
100
101 QSize previewSize() const;
103 void setPreviewSize(const QSize &size);
104 bool setPreviewTexture(AndroidSurfaceTexture *surfaceTexture);
105 bool setPreviewDisplay(AndroidSurfaceHolder *surfaceHolder);
106 void setDisplayOrientation(int degrees);
107
108 bool isZoomSupported();
109 int getMaxZoom();
110 QList<int> getZoomRatios();
111 int getZoom();
112 void setZoom(int value);
113
116 void setFlashMode(const QString &value);
117
120 void setFocusMode(const QString &value);
121
123 QList<QRect> getFocusAreas();
124 void setFocusAreas(const QList<QRect> &areas);
125
126 void autoFocus();
127 void cancelAutoFocus();
128
130 bool getAutoExposureLock();
131 void setAutoExposureLock(bool toggle);
132
135 void setAutoWhiteBalanceLock(bool toggle);
136
142
145 void setSceneMode(const QString &value);
146
149 void setWhiteBalance(const QString &value);
150
151 void setRotation(int rotation);
152 int getRotation() const;
153
154 QList<QCameraFormat> getSupportedFormats();
155 QList<QSize> getSupportedPictureSizes();
156 QList<QSize> getSupportedVideoSizes();
157 void setPictureSize(const QSize &size);
158 void setJpegQuality(int quality);
159
160 void startPreview();
161 void stopPreview();
163
164 void takePicture();
165
167 void notifyNewFrames(bool notify);
171
172 static int getNumberOfCameras();
173 static void getCameraInfo(int id, QCameraDevicePrivate *info);
177
178 static bool registerNativeMethods();
184
186 void autoFocusComplete(bool success);
187
189
195
196private:
198
199 Q_DECLARE_PRIVATE(AndroidCamera)
201 QScopedPointer<QThread> m_worker;
202};
203
205
207
208#endif // ANDROIDCAMERA_H
void autoFocusStarted()
void setupPreviewFrameCallback()
QJniObject getCameraObject()
ImageFormat getPreviewFormat()
QSize getPreferredPreviewSizeForVideo()
void setPictureSize(const QSize &size)
void setFlashMode(const QString &value)
void previewStarted()
static AndroidCamera::ImageFormat AndroidImageFormatFromQtPixelFormat(QVideoFrameFormat::PixelFormat)
void pictureExposed()
QSize actualPreviewSize()
void takePictureFailed()
int getExposureCompensation()
QString getWhiteBalance()
void setExposureCompensation(int value)
bool getAutoExposureLock()
float getExposureCompensationStep()
QList< QCameraFormat > getSupportedFormats()
void setFocusAreas(const QList< QRect > &areas)
void previewStopped()
bool getAutoWhiteBalanceLock()
QList< QRect > getFocusAreas()
void stopPreviewSynchronous()
QStringList getSupportedFocusModes()
bool setPreviewDisplay(AndroidSurfaceHolder *surfaceHolder)
void setRotation(int rotation)
QList< FpsRange > getSupportedPreviewFpsRange()
void newPreviewFrame(const QVideoFrame &frame)
bool isAutoWhiteBalanceLockSupported()
static int getNumberOfCameras()
void previewSizeChanged()
QJniObject getParametersObject()
void previewFailedToStart()
static QVideoFrameFormat::PixelFormat QtPixelFormatFromAndroidImageFormat(AndroidCamera::ImageFormat)
void setWhiteBalance(const QString &value)
void lastPreviewFrameFetched(const QVideoFrame &frame)
bool setPreviewTexture(AndroidSurfaceTexture *surfaceTexture)
void setAutoExposureLock(bool toggle)
FpsRange getPreviewFpsRange()
void fetchLastPreviewFrame()
void setPreviewFpsRange(FpsRange)
QString getFocusMode()
void pictureCaptured(const QByteArray &frame, QVideoFrameFormat::PixelFormat format, QSize size, int bytesPerLine)
void autoFocusComplete(bool success)
void setJpegQuality(int quality)
QStringList getSupportedSceneModes()
QList< QSize > getSupportedPictureSizes()
static void getCameraInfo(int id, QCameraDevicePrivate *info)
QList< QSize > getSupportedPreviewSizes()
QString getSceneMode()
int getRotation() const
static AndroidCamera * open(int cameraId)
void setSceneMode(const QString &value)
QList< QSize > getSupportedVideoSizes()
static bool registerNativeMethods()
void setFocusMode(const QString &value)
QString getFlashMode()
QList< ImageFormat > getSupportedPreviewFormats()
static bool requestCameraPermission()
void setDisplayOrientation(int degrees)
QSize previewSize() const
QStringList getSupportedWhiteBalance()
int getMinExposureCompensation()
CameraFacing getFacing()
void notifyNewFrames(bool notify)
void whiteBalanceChanged()
void setPreviewSize(const QSize &size)
int getMaxExposureCompensation()
void setPreviewFormat(ImageFormat fmt)
int cameraId() const
QStringList getSupportedFlashModes()
QList< int > getZoomRatios()
void setAutoWhiteBalanceLock(bool toggle)
void setZoom(int value)
bool isAutoExposureLockSupported()
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
PixelFormat
Enumerates video data types.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1525
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei range
GLint GLsizei GLsizei GLenum format
#define Q_ENUM(x)
#define Q_OBJECT
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
QVideoFrameFormat::PixelFormat fmt
QFrame frame
[0]
QHostInfo info
[0]
static FpsRange makeFromQReal(qreal min, qreal max)