1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the plugins of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qdeclarativecamera_p.h" |
41 | #include "qdeclarativecameraimageprocessing_p.h" |
42 | |
43 | QT_BEGIN_NAMESPACE |
44 | |
45 | /*! |
46 | \qmltype CameraImageProcessing |
47 | \instantiates QDeclarativeCameraImageProcessing |
48 | \inqmlmodule QtMultimedia |
49 | \brief An interface for camera capture related settings. |
50 | \ingroup multimedia_qml |
51 | \ingroup camera_qml |
52 | |
53 | CameraImageProcessing provides control over post-processing |
54 | done by the camera middleware, including white balance adjustments, |
55 | contrast, saturation, sharpening, and denoising |
56 | |
57 | It should not be constructed separately, instead the |
58 | \c imageProcessing property of a \l Camera should be used. |
59 | |
60 | \qml |
61 | |
62 | Camera { |
63 | id: camera |
64 | |
65 | imageProcessing { |
66 | whiteBalanceMode: Camera.WhiteBalanceTungsten |
67 | contrast: 0.66 |
68 | saturation: -0.5 |
69 | } |
70 | } |
71 | |
72 | \endqml |
73 | |
74 | |
75 | */ |
76 | /*! |
77 | \class QDeclarativeCameraImageProcessing |
78 | \internal |
79 | \brief The CameraCapture provides an interface for camera capture related settings |
80 | */ |
81 | |
82 | |
83 | QDeclarativeCameraImageProcessing::QDeclarativeCameraImageProcessing(QCamera *camera, QObject *parent) : |
84 | QObject(parent) |
85 | { |
86 | m_imageProcessing = camera->imageProcessing(); |
87 | |
88 | connect(sender: camera, signal: QOverload<bool>::of(ptr: &QCamera::availabilityChanged), |
89 | receiver: this, slot: &QDeclarativeCameraImageProcessing::availableChanged); |
90 | connect(sender: camera, signal: &QCamera::statusChanged, slot: [this](QCamera::Status status) { |
91 | if (status != QCamera::UnloadedStatus && status != QCamera::LoadedStatus |
92 | && status != QCamera::ActiveStatus) { |
93 | return; |
94 | } |
95 | |
96 | emit supportedColorFiltersChanged(); |
97 | emit supportedWhiteBalanceModesChanged(); |
98 | }); |
99 | } |
100 | |
101 | QDeclarativeCameraImageProcessing::~QDeclarativeCameraImageProcessing() |
102 | { |
103 | } |
104 | |
105 | /*! |
106 | \qmlproperty enumeration QtMultimedia::CameraImageProcessing::whiteBalanceMode |
107 | |
108 | \table |
109 | \header \li Value \li Description |
110 | \row \li WhiteBalanceManual \li Manual white balance. In this mode the manual white balance property value is used. |
111 | \row \li WhiteBalanceAuto \li Auto white balance mode. |
112 | \row \li WhiteBalanceSunlight \li Sunlight white balance mode. |
113 | \row \li WhiteBalanceCloudy \li Cloudy white balance mode. |
114 | \row \li WhiteBalanceShade \li Shade white balance mode. |
115 | \row \li WhiteBalanceTungsten \li Tungsten white balance mode. |
116 | \row \li WhiteBalanceFluorescent \li Fluorescent white balance mode. |
117 | \row \li WhiteBalanceFlash \li Flash white balance mode. |
118 | \row \li WhiteBalanceSunset \li Sunset white balance mode. |
119 | \row \li WhiteBalanceVendor \li Vendor defined white balance mode. |
120 | \endtable |
121 | |
122 | \sa manualWhiteBalance |
123 | */ |
124 | QDeclarativeCameraImageProcessing::WhiteBalanceMode QDeclarativeCameraImageProcessing::whiteBalanceMode() const |
125 | { |
126 | return WhiteBalanceMode(m_imageProcessing->whiteBalanceMode()); |
127 | } |
128 | |
129 | void QDeclarativeCameraImageProcessing::setWhiteBalanceMode(QDeclarativeCameraImageProcessing::WhiteBalanceMode mode) const |
130 | { |
131 | if (whiteBalanceMode() != mode) { |
132 | m_imageProcessing->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode(mode)); |
133 | emit whiteBalanceModeChanged(whiteBalanceMode()); |
134 | } |
135 | } |
136 | |
137 | /*! |
138 | \qmlproperty qreal QtMultimedia::CameraImageProcessing::manualWhiteBalance |
139 | |
140 | The color temperature used when in manual white balance mode (WhiteBalanceManual). |
141 | The units are Kelvin. |
142 | |
143 | \sa whiteBalanceMode |
144 | */ |
145 | qreal QDeclarativeCameraImageProcessing::manualWhiteBalance() const |
146 | { |
147 | return m_imageProcessing->manualWhiteBalance(); |
148 | } |
149 | |
150 | void QDeclarativeCameraImageProcessing::setManualWhiteBalance(qreal colorTemp) const |
151 | { |
152 | if (manualWhiteBalance() != colorTemp) { |
153 | m_imageProcessing->setManualWhiteBalance(colorTemp); |
154 | emit manualWhiteBalanceChanged(manualWhiteBalance()); |
155 | } |
156 | } |
157 | |
158 | /*! |
159 | \qmlproperty qreal QtMultimedia::CameraImageProcessing::brightness |
160 | |
161 | Image brightness adjustment. |
162 | Valid brightness adjustment values range between -1.0 and 1.0, with a default of 0. |
163 | |
164 | \since 5.7 |
165 | */ |
166 | qreal QDeclarativeCameraImageProcessing::brightness() const |
167 | { |
168 | return m_imageProcessing->brightness(); |
169 | } |
170 | |
171 | void QDeclarativeCameraImageProcessing::setBrightness(qreal value) |
172 | { |
173 | if (value != brightness()) { |
174 | m_imageProcessing->setBrightness(value); |
175 | emit brightnessChanged(brightness()); |
176 | } |
177 | } |
178 | |
179 | /*! |
180 | \qmlproperty qreal QtMultimedia::CameraImageProcessing::contrast |
181 | |
182 | Image contrast adjustment. |
183 | Valid contrast adjustment values range between -1.0 and 1.0, with a default of 0. |
184 | */ |
185 | qreal QDeclarativeCameraImageProcessing::contrast() const |
186 | { |
187 | return m_imageProcessing->contrast(); |
188 | } |
189 | |
190 | void QDeclarativeCameraImageProcessing::setContrast(qreal value) |
191 | { |
192 | if (value != contrast()) { |
193 | m_imageProcessing->setContrast(value); |
194 | emit contrastChanged(contrast()); |
195 | } |
196 | } |
197 | |
198 | /*! |
199 | \qmlproperty qreal QtMultimedia::CameraImageProcessing::saturation |
200 | |
201 | Image saturation adjustment. |
202 | Valid saturation adjustment values range between -1.0 and 1.0, the default is 0. |
203 | */ |
204 | qreal QDeclarativeCameraImageProcessing::saturation() const |
205 | { |
206 | return m_imageProcessing->saturation(); |
207 | } |
208 | |
209 | void QDeclarativeCameraImageProcessing::setSaturation(qreal value) |
210 | { |
211 | if (value != saturation()) { |
212 | m_imageProcessing->setSaturation(value); |
213 | emit saturationChanged(saturation()); |
214 | } |
215 | } |
216 | |
217 | /*! |
218 | \qmlproperty qreal QtMultimedia::CameraImageProcessing::sharpeningLevel |
219 | |
220 | Adjustment of sharpening level applied to image. |
221 | |
222 | Valid sharpening level values range between -1.0 for for sharpening disabled, |
223 | 0 for default sharpening level and 1.0 for maximum sharpening applied. |
224 | */ |
225 | qreal QDeclarativeCameraImageProcessing::sharpeningLevel() const |
226 | { |
227 | return m_imageProcessing->sharpeningLevel(); |
228 | } |
229 | |
230 | void QDeclarativeCameraImageProcessing::setSharpeningLevel(qreal value) |
231 | { |
232 | if (value != sharpeningLevel()) { |
233 | m_imageProcessing->setSharpeningLevel(value); |
234 | emit sharpeningLevelChanged(sharpeningLevel()); |
235 | } |
236 | } |
237 | |
238 | /*! |
239 | \qmlproperty qreal QtMultimedia::CameraImageProcessing::denoisingLevel |
240 | |
241 | Adjustment of denoising applied to image. |
242 | |
243 | Valid denoising level values range between -1.0 for for denoising disabled, |
244 | 0 for default denoising level and 1.0 for maximum denoising applied. |
245 | */ |
246 | qreal QDeclarativeCameraImageProcessing::denoisingLevel() const |
247 | { |
248 | return m_imageProcessing->denoisingLevel(); |
249 | } |
250 | |
251 | void QDeclarativeCameraImageProcessing::setDenoisingLevel(qreal value) |
252 | { |
253 | if (value != denoisingLevel()) { |
254 | m_imageProcessing->setDenoisingLevel(value); |
255 | emit denoisingLevelChanged(denoisingLevel()); |
256 | } |
257 | } |
258 | |
259 | /*! |
260 | \qmlproperty enumeration QtMultimedia::CameraImageProcessing::colorFilter |
261 | |
262 | This property holds which color filter if any will be applied to image data captured by the camera. |
263 | |
264 | It can be one of: |
265 | |
266 | \table |
267 | \row \li CameraImageProcessing.ColorFilterNone \li No filter is applied to images. |
268 | \row \li CameraImageProcessing.ColorFilterGrayscale \li A grayscale filter. |
269 | \row \li CameraImageProcessing.ColorFilterNegative \li A negative filter. |
270 | \row \li CameraImageProcessing.ColorFilterSolarize \li A solarize filter. |
271 | \row \li CameraImageProcessing.ColorFilterSepia \li A sepia filter. |
272 | \row \li CameraImageProcessing.ColorFilterPosterize \li A posterize filter. |
273 | \row \li CameraImageProcessing.ColorFilterWhiteboard \li A whiteboard filter. |
274 | \row \li CameraImageProcessing.ColorFilterBlackboard \li A blackboard filter. |
275 | \row \li CameraImageProcessing.ColorFilterAqua \li An aqua filter. |
276 | \row \li CameraImageProcessing.ColorFilterVendor \li The base value for vendor defined filters. |
277 | \endtable |
278 | |
279 | \since 5.5 |
280 | */ |
281 | |
282 | QDeclarativeCameraImageProcessing::ColorFilter QDeclarativeCameraImageProcessing::colorFilter() const |
283 | { |
284 | return ColorFilter(m_imageProcessing->colorFilter()); |
285 | } |
286 | |
287 | /*! |
288 | \qmlproperty bool QtMultimedia::CameraImageProcessing::isAvailable |
289 | |
290 | This property holds if image processing related settings are supported by this camera. |
291 | |
292 | \since 5.11 |
293 | */ |
294 | bool QDeclarativeCameraImageProcessing::isAvailable() const |
295 | { |
296 | return m_imageProcessing->isAvailable(); |
297 | } |
298 | |
299 | /*! |
300 | \qmlproperty list<ColorFilter> QtMultimedia::CameraImageProcessing::supportedColorFilters |
301 | |
302 | This property holds the supported color filters by this camera. |
303 | |
304 | \since 5.11 |
305 | */ |
306 | QVariantList QDeclarativeCameraImageProcessing::supportedColorFilters() const |
307 | { |
308 | QVariantList supportedFilters; |
309 | |
310 | for (int i = int(ColorFilterNone); i <= int(ColorFilterVendor); ++i) { |
311 | if (m_imageProcessing->isColorFilterSupported(filter: (QCameraImageProcessing::ColorFilter) i)) |
312 | supportedFilters.append(t: i); |
313 | } |
314 | |
315 | return supportedFilters; |
316 | } |
317 | |
318 | /*! |
319 | \qmlproperty list<WhiteBalanceMode> QtMultimedia::CameraImageProcessing::supportedWhiteBalanceModes |
320 | |
321 | This property holds the supported white balance modes by this camera. |
322 | |
323 | \since 5.11 |
324 | */ |
325 | QVariantList QDeclarativeCameraImageProcessing::supportedWhiteBalanceModes() const |
326 | { |
327 | QVariantList supportedModes; |
328 | |
329 | for (int i = int(WhiteBalanceAuto); i <= int(WhiteBalanceVendor); i++) { |
330 | if (m_imageProcessing->isWhiteBalanceModeSupported(mode: QCameraImageProcessing::WhiteBalanceMode(i))) |
331 | supportedModes.append(t: i); |
332 | } |
333 | |
334 | return supportedModes; |
335 | } |
336 | |
337 | void QDeclarativeCameraImageProcessing::setColorFilter(ColorFilter filter) |
338 | { |
339 | if (this->colorFilter() != filter) { |
340 | m_imageProcessing->setColorFilter(QCameraImageProcessing::ColorFilter(filter)); |
341 | emit colorFilterChanged(); |
342 | } |
343 | } |
344 | |
345 | /*! |
346 | \qmlsignal QtMultimedia::Camera::whiteBalanceModeChanged() |
347 | This signal is emitted when the \c whiteBalanceMode property is changed. |
348 | |
349 | The corresponding handler is \c onWhiteBalanceModeChanged. |
350 | */ |
351 | |
352 | /*! |
353 | \qmlsignal QtMultimedia::Camera::manualWhiteBalanceChanged() |
354 | This signal is emitted when the \c manualWhiteBalance property is changed. |
355 | |
356 | The corresponding handler is \c onManualWhiteBalanceChanged. |
357 | */ |
358 | |
359 | QT_END_NAMESPACE |
360 | |
361 | #include "moc_qdeclarativecameraimageprocessing_p.cpp" |
362 | |