File size: 8,285 Bytes
3bb804c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// qcamera.sip generated by MetaSIP
//
// This file is part of the QtMultimedia Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
// 
// This file is part of PyQt6.
// 
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file.  Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
// 
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license.  For more information contact
// info@riverbankcomputing.com.
// 
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.


%If (Qt_6_2_0 -)

class QCamera : public QObject
{
%TypeHeaderCode
#include <qcamera.h>
%End

%ConvertToSubClassCode
    static struct class_graph {
        const char *name;
        sipTypeDef **type;
        int yes, no;
    } graph[] = {
    #if QT_VERSION >= 0x060800
        {sipName_QAudioBufferInput, &sipType_QAudioBufferInput, -1, 1},
    #else
        {0, 0, -1, 1},
    #endif
    #if QT_VERSION >= 0x060800
        {sipName_QAudioBufferOutput, &sipType_QAudioBufferOutput, -1, 2},
    #else
        {0, 0, -1, 2},
    #endif
        {sipName_QAudioDecoder, &sipType_QAudioDecoder, -1, 3},
        {sipName_QAudioInput, &sipType_QAudioInput, -1, 4},
        {sipName_QAudioOutput, &sipType_QAudioOutput, -1, 5},
        {sipName_QAudioSink, &sipType_QAudioSink, -1, 6},
        {sipName_QAudioSource, &sipType_QAudioSource, -1, 7},
        {sipName_QCamera, &sipType_QCamera, -1, 8},
        {sipName_QImageCapture, &sipType_QImageCapture, -1, 9},
        {sipName_QMediaCaptureSession, &sipType_QMediaCaptureSession, -1, 10},
        {sipName_QMediaDevices, &sipType_QMediaDevices, -1, 11},
        {sipName_QMediaPlayer, &sipType_QMediaPlayer, -1, 12},
        {sipName_QMediaRecorder, &sipType_QMediaRecorder, -1, 13},
    #if QT_VERSION >= 0x060500
        {sipName_QScreenCapture, &sipType_QScreenCapture, -1, 14},
    #else
        {0, 0, -1, 14},
    #endif
        {sipName_QSoundEffect, &sipType_QSoundEffect, -1, 15},
    #if QT_VERSION >= 0x060800
        {sipName_QVideoFrameInput, &sipType_QVideoFrameInput, -1, 16},
    #else
        {0, 0, -1, 16},
    #endif
        {sipName_QVideoSink, &sipType_QVideoSink, -1, 17},
    #if QT_VERSION >= 0x060600
        {sipName_QWindowCapture, &sipType_QWindowCapture, -1, -1},
    #else
        {0, 0, -1, -1},
    #endif
    };
    
    int i = 0;
    
    sipType = NULL;
    
    do
    {
        struct class_graph *cg = &graph[i];
    
        if (cg->name != NULL && sipCpp->inherits(cg->name))
        {
            sipType = *cg->type;
            i = cg->yes;
        }
        else
            i = cg->no;
    }
    while (i >= 0);
%End



public:
    enum Error
    {
        NoError,
        CameraError,
    };

    enum FocusMode
    {
        FocusModeAuto,
        FocusModeAutoNear,
        FocusModeAutoFar,
        FocusModeHyperfocal,
        FocusModeInfinity,
        FocusModeManual,
    };

    enum FlashMode
    {
        FlashOff,
        FlashOn,
        FlashAuto,
    };

    enum TorchMode
    {
        TorchOff,
        TorchOn,
        TorchAuto,
    };

    enum ExposureMode
    {
        ExposureAuto,
        ExposureManual,
        ExposurePortrait,
        ExposureNight,
        ExposureSports,
        ExposureSnow,
        ExposureBeach,
        ExposureAction,
        ExposureLandscape,
        ExposureNightPortrait,
        ExposureTheatre,
        ExposureSunset,
        ExposureSteadyPhoto,
        ExposureFireworks,
        ExposureParty,
        ExposureCandlelight,
        ExposureBarcode,
    };

    enum WhiteBalanceMode
    {
        WhiteBalanceAuto,
        WhiteBalanceManual,
        WhiteBalanceSunlight,
        WhiteBalanceCloudy,
        WhiteBalanceShade,
        WhiteBalanceTungsten,
        WhiteBalanceFluorescent,
        WhiteBalanceFlash,
        WhiteBalanceSunset,
    };

    enum class Feature
    {
        ColorTemperature,
        ExposureCompensation,
        IsoSensitivity,
        ManualExposureTime,
        CustomFocusPoint,
        FocusDistance,
    };

    typedef QFlags<QCamera::Feature> Features;
    QCamera(const QCameraDevice &cameraDevice, QObject *parent /TransferThis/ = 0);
    QCamera(QCameraDevice::Position position, QObject *parent /TransferThis/ = 0);
    explicit QCamera(QObject *parent /TransferThis/ = 0);
    virtual ~QCamera();
    bool isAvailable() const;
    bool isActive() const;
    QMediaCaptureSession *captureSession() const;
    QCameraDevice cameraDevice() const;
    void setCameraDevice(const QCameraDevice &cameraDevice);
    QCameraFormat cameraFormat() const;
    void setCameraFormat(const QCameraFormat &format);

    QCamera::Error error() const;
    QString errorString() const;

    QCamera::Features supportedFeatures() const;

    QCamera::FocusMode focusMode() const;
    void setFocusMode(QCamera::FocusMode mode);
    bool isFocusModeSupported(QCamera::FocusMode mode) const;
    QPointF focusPoint() const;
    QPointF customFocusPoint() const;
    void setCustomFocusPoint(const QPointF &point);
    void setFocusDistance(float d);
    float focusDistance() const;
    float minimumZoomFactor() const;
    float maximumZoomFactor() const;
    float zoomFactor() const;
    void setZoomFactor(float factor);

    QCamera::FlashMode flashMode() const;
    bool isFlashModeSupported(QCamera::FlashMode mode) const;
    bool isFlashReady() const;

    QCamera::TorchMode torchMode() const;
    bool isTorchModeSupported(QCamera::TorchMode mode) const;

    QCamera::ExposureMode exposureMode() const;
    bool isExposureModeSupported(QCamera::ExposureMode mode) const;
    float exposureCompensation() const;
    int isoSensitivity() const;
    int manualIsoSensitivity() const;
    float exposureTime() const;
    float manualExposureTime() const;
    int minimumIsoSensitivity() const;
    int maximumIsoSensitivity() const;
    float minimumExposureTime() const;
    float maximumExposureTime() const;

    QCamera::WhiteBalanceMode whiteBalanceMode() const;
    bool isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const;
    int colorTemperature() const;

public slots:
    void setActive(bool active);
    void start();
    void stop();
    void zoomTo(float zoom, float rate);
    void setFlashMode(QCamera::FlashMode mode);
    void setTorchMode(QCamera::TorchMode mode);
    void setExposureMode(QCamera::ExposureMode mode);
    void setExposureCompensation(float ev);
    void setManualIsoSensitivity(int iso);
    void setAutoIsoSensitivity();
    void setManualExposureTime(float seconds);
    void setAutoExposureTime();
    void setWhiteBalanceMode(QCamera::WhiteBalanceMode mode);
    void setColorTemperature(int colorTemperature);



signals:
    void activeChanged(bool);
    void errorChanged();
    void errorOccurred(QCamera::Error error, const QString &errorString);
    void cameraDeviceChanged();
    void cameraFormatChanged();
    void supportedFeaturesChanged();
    void focusModeChanged();
    void zoomFactorChanged(float);
    void minimumZoomFactorChanged(float);
    void maximumZoomFactorChanged(float);
    void focusDistanceChanged(float);
    void customFocusPointChanged();
    void flashReady(bool);
    void flashModeChanged();
    void torchModeChanged();
    void exposureTimeChanged(float speed);
    void isoSensitivityChanged(int);
    void exposureCompensationChanged(float);
    void exposureModeChanged();
    void whiteBalanceModeChanged() const;
    void colorTemperatureChanged() const;
    void focusPointChanged();
    void manualExposureTimeChanged(float speed);
    void manualIsoSensitivityChanged(int);
};

%End