| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | |
| 5 | #include "qcamera_p.h" |
| 6 | |
| 7 | #include <qcameradevice.h> |
| 8 | #include <private/qplatformcamera_p.h> |
| 9 | #include <private/qplatformimagecapture_p.h> |
| 10 | #include <private/qplatformmediaintegration_p.h> |
| 11 | #include <private/qplatformmediacapture_p.h> |
| 12 | #include <qmediadevices.h> |
| 13 | #include <qmediacapturesession.h> |
| 14 | |
| 15 | #include <QDebug> |
| 16 | |
| 17 | QT_BEGIN_NAMESPACE |
| 18 | |
| 19 | /*! |
| 20 | \class QCamera |
| 21 | |
| 22 | |
| 23 | \brief The QCamera class provides interface for system camera devices. |
| 24 | |
| 25 | \inmodule QtMultimedia |
| 26 | \ingroup multimedia |
| 27 | \ingroup multimedia_camera |
| 28 | |
| 29 | QCamera can be used within a QMediaCaptureSession for video recording and image taking. |
| 30 | |
| 31 | You can use QCameraDevice to list available cameras and choose which one to use. |
| 32 | |
| 33 | \snippet multimedia-snippets/camera.cpp Camera selection |
| 34 | |
| 35 | On hardware that supports it, QCamera lets you adjust the focus |
| 36 | and zoom. This also includes functionality such as a |
| 37 | "Macro" mode for close up work (e.g. reading barcodes, or |
| 38 | recognizing letters), or "touch to focus" - indicating an |
| 39 | interesting area of the image for the hardware to attempt |
| 40 | to focus on. |
| 41 | |
| 42 | \snippet multimedia-snippets/camera.cpp Camera custom focus |
| 43 | |
| 44 | The \l minimumZoomFactor() and \l maximumZoomFactor() methods provide the |
| 45 | range of supported zoom factors. The \l zoomTo() method allows changing |
| 46 | the zoom factor. |
| 47 | |
| 48 | \snippet multimedia-snippets/camera.cpp Camera zoom |
| 49 | |
| 50 | |
| 51 | After capturing the raw data for a camera frame, the camera hardware and |
| 52 | software performs various image processing tasks to produce the final |
| 53 | image. This includes compensating for ambient light color, reducing |
| 54 | noise, as well as making some other adjustments to the image. |
| 55 | |
| 56 | You can control many of these processing steps through the Camera properties. |
| 57 | For example, you can set the white balance (or color temperature) used |
| 58 | for processing images: |
| 59 | |
| 60 | \snippet multimedia-snippets/camera.cpp Camera image whitebalance |
| 61 | |
| 62 | For more information on image processing of camera frames, see |
| 63 | \l {camera_image_processing}{Camera Image Processing}. |
| 64 | |
| 65 | See the \l{Camera Overview}{camera overview} for more information. |
| 66 | |
| 67 | \note On WebAssembly platform, due to it's asynchronous nature, |
| 68 | QMediaDevices::videoInputsChanged() signal is emitted when the list of |
| 69 | video inputs is ready. User permissions are required. Works only on secure https contexts. |
| 70 | */ |
| 71 | |
| 72 | /*! |
| 73 | \qmltype Camera |
| 74 | \nativetype QCamera |
| 75 | \inqmlmodule QtMultimedia |
| 76 | \brief An interface for camera settings related to focus and zoom. |
| 77 | \ingroup multimedia_qml |
| 78 | \ingroup camera_qml |
| 79 | |
| 80 | The Camera element can be used within a \l CaptureSession for video recording |
| 81 | and image taking. |
| 82 | |
| 83 | You can use \l MediaDevices to list available cameras and choose which one to use. |
| 84 | |
| 85 | \qml |
| 86 | MediaDevices { |
| 87 | id: mediaDevices |
| 88 | } |
| 89 | CaptureSession { |
| 90 | camera: Camera { |
| 91 | cameraDevice: mediaDevices.defaultVideoInput |
| 92 | } |
| 93 | } |
| 94 | \endqml |
| 95 | |
| 96 | On hardware that supports it, QCamera lets you adjust the focus |
| 97 | and zoom. This also includes functionality such as a |
| 98 | "Macro" mode for close up work (e.g. reading barcodes, or |
| 99 | recognizing letters), or "touch to focus" - indicating an |
| 100 | interesting area of the image for the hardware to attempt |
| 101 | to focus on. |
| 102 | |
| 103 | \qml |
| 104 | |
| 105 | Item { |
| 106 | width: 640 |
| 107 | height: 360 |
| 108 | |
| 109 | CaptureSession { |
| 110 | camera: Camera { |
| 111 | id: camera |
| 112 | |
| 113 | focusMode: Camera.FocusModeAutoNear |
| 114 | customFocusPoint: Qt.point(0.2, 0.2) // Focus relative to top-left corner |
| 115 | } |
| 116 | videoOutput: videoOutput |
| 117 | } |
| 118 | |
| 119 | VideoOutput { |
| 120 | id: videoOutput |
| 121 | anchors.fill: parent |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | \endqml |
| 126 | |
| 127 | The \l minimumZoomFactor and \l maximumZoomFactor properties provide the |
| 128 | range of supported zoom factors. The \l zoomFactor property allows changing |
| 129 | the zoom factor. |
| 130 | |
| 131 | \qml |
| 132 | Camera { |
| 133 | zoomFactor: maximumZoomFactor // zoom in as much as possible |
| 134 | } |
| 135 | \endqml |
| 136 | |
| 137 | After capturing the raw data for a camera frame, the camera hardware and |
| 138 | software performs various image processing tasks to produce the final |
| 139 | image. This includes compensating for ambient light color, reducing |
| 140 | noise, as well as making some other adjustments to the image. |
| 141 | |
| 142 | You can control many of these processing steps through the Camera properties. |
| 143 | For example, you can set the white balance (or color temperature) used |
| 144 | for processing images: |
| 145 | |
| 146 | \qml |
| 147 | Camera { |
| 148 | whiteBalanceMode: Camera.WhiteBalanceManual |
| 149 | colorTemperature: 5600 |
| 150 | } |
| 151 | \endqml |
| 152 | |
| 153 | For more information on image processing of camera frames, see |
| 154 | \l {camera_image_processing}{Camera Image Processing}. |
| 155 | |
| 156 | See the \l{Camera Overview}{camera overview} for more information. |
| 157 | */ |
| 158 | |
| 159 | void QCameraPrivate::init(const QCameraDevice &device) |
| 160 | { |
| 161 | Q_Q(QCamera); |
| 162 | |
| 163 | auto maybeControl = QPlatformMediaIntegration::instance()->createCamera(q); |
| 164 | if (!maybeControl) { |
| 165 | qWarning() << "Failed to initialize QCamera" << maybeControl.error(); |
| 166 | return; |
| 167 | } |
| 168 | control = maybeControl.value(); |
| 169 | cameraDevice = !device.isNull() ? device : QMediaDevices::defaultVideoInput(); |
| 170 | if (cameraDevice.isNull()) |
| 171 | control->updateError(error: QCamera::CameraError, QStringLiteral("No camera detected" )); |
| 172 | control->setCamera(cameraDevice); |
| 173 | q->connect(sender: control, signal: &QPlatformVideoSource::activeChanged, context: q, slot: &QCamera::activeChanged); |
| 174 | q->connect(sender: control, signal: &QPlatformCamera::errorChanged, context: q, slot: &QCamera::errorChanged); |
| 175 | q->connect(sender: control, signal: &QPlatformCamera::errorOccurred, context: q, slot: &QCamera::errorOccurred); |
| 176 | } |
| 177 | |
| 178 | /*! |
| 179 | Construct a QCamera with a \a parent. |
| 180 | |
| 181 | Selects the default camera on the system if more than one camera is available. |
| 182 | */ |
| 183 | |
| 184 | QCamera::QCamera(QObject *parent) |
| 185 | : QCamera(QMediaDevices::defaultVideoInput(), parent) |
| 186 | { |
| 187 | } |
| 188 | |
| 189 | /*! |
| 190 | \since 5.3 |
| 191 | |
| 192 | Construct a QCamera from a camera description \a cameraDevice and \a parent. |
| 193 | */ |
| 194 | |
| 195 | QCamera::QCamera(const QCameraDevice &cameraDevice, QObject *parent) |
| 196 | : QObject(*new QCameraPrivate, parent) |
| 197 | { |
| 198 | Q_D(QCamera); |
| 199 | d->init(device: cameraDevice); |
| 200 | } |
| 201 | |
| 202 | /*! |
| 203 | \since 5.3 |
| 204 | |
| 205 | Construct a QCamera which uses a hardware camera located a the specified \a position. |
| 206 | |
| 207 | For example on a mobile phone it can be used to easily choose between front-facing and |
| 208 | back-facing cameras. |
| 209 | |
| 210 | If no camera is available at the specified \a position or if \a position is |
| 211 | QCameraDevice::UnspecifiedPosition, the default camera is used. |
| 212 | */ |
| 213 | |
| 214 | QCamera::QCamera(QCameraDevice::Position position, QObject *parent) |
| 215 | : QObject(*new QCameraPrivate, parent) |
| 216 | { |
| 217 | Q_D(QCamera); |
| 218 | |
| 219 | QCameraDevice device; |
| 220 | auto cameras = QMediaDevices::videoInputs(); |
| 221 | for (const auto &c : std::as_const(t&: cameras)) { |
| 222 | if (c.position() == position) { |
| 223 | device = c; |
| 224 | break; |
| 225 | } |
| 226 | } |
| 227 | d->init(device); |
| 228 | } |
| 229 | |
| 230 | /*! |
| 231 | Destroys the camera object. |
| 232 | */ |
| 233 | |
| 234 | QCamera::~QCamera() |
| 235 | { |
| 236 | Q_D(QCamera); |
| 237 | if (d->captureSession) |
| 238 | d->captureSession->setCamera(nullptr); |
| 239 | } |
| 240 | |
| 241 | /*! |
| 242 | Returns true if the camera can be used. |
| 243 | */ |
| 244 | bool QCamera::isAvailable() const |
| 245 | { |
| 246 | Q_D(const QCamera); |
| 247 | return d->control && !d->cameraDevice.isNull(); |
| 248 | } |
| 249 | |
| 250 | /*! \qmlproperty bool QtMultimedia::Camera::active |
| 251 | |
| 252 | Describes whether the camera is currently active. |
| 253 | */ |
| 254 | |
| 255 | /*! \property QCamera::active |
| 256 | |
| 257 | Describes whether the camera is currently active. |
| 258 | */ |
| 259 | |
| 260 | /*! |
| 261 | Returns true if the camera is currently active. |
| 262 | */ |
| 263 | bool QCamera::isActive() const |
| 264 | { |
| 265 | Q_D(const QCamera); |
| 266 | return d->control && d->control->isActive(); |
| 267 | } |
| 268 | |
| 269 | /*! |
| 270 | Turns the camera on if \a active is \c{true}, or off if it's \c{false}. |
| 271 | */ |
| 272 | void QCamera::setActive(bool active) |
| 273 | { |
| 274 | Q_D(const QCamera); |
| 275 | if (d->control) |
| 276 | d->control->setActive(active); |
| 277 | } |
| 278 | |
| 279 | /*! |
| 280 | \qmlproperty enumeration QtMultimedia::Camera::error |
| 281 | |
| 282 | Returns the error state of the camera. |
| 283 | |
| 284 | \sa QCamera::Error |
| 285 | */ |
| 286 | |
| 287 | /*! |
| 288 | \property QCamera::error |
| 289 | |
| 290 | Returns the error state of the camera. |
| 291 | */ |
| 292 | |
| 293 | QCamera::Error QCamera::error() const |
| 294 | { |
| 295 | Q_D(const QCamera); |
| 296 | |
| 297 | return d->control ? d->control->error() : QCamera::CameraError; |
| 298 | } |
| 299 | |
| 300 | /*! |
| 301 | \qmlproperty string QtMultimedia::Camera::errorString |
| 302 | |
| 303 | Returns a human readable string describing a camera's error state. |
| 304 | */ |
| 305 | |
| 306 | /*! |
| 307 | \property QCamera::errorString |
| 308 | |
| 309 | Returns a human readable string describing a camera's error state. |
| 310 | */ |
| 311 | QString QCamera::errorString() const |
| 312 | { |
| 313 | Q_D(const QCamera); |
| 314 | |
| 315 | return d->control ? d->control->errorString() |
| 316 | : QStringLiteral("Camera is not supported on the platform" ); |
| 317 | } |
| 318 | |
| 319 | /*! \enum QCamera::Feature |
| 320 | |
| 321 | Describes a set of features supported by the camera. The returned value can be a |
| 322 | combination of: |
| 323 | |
| 324 | \value ColorTemperature |
| 325 | The Camera supports setting a custom \l{colorTemperature}. |
| 326 | \value ExposureCompensation |
| 327 | The Camera supports setting a custom \l{exposureCompensation}. |
| 328 | \value IsoSensitivity |
| 329 | The Camera supports setting a custom \l{isoSensitivity}. |
| 330 | \value ManualExposureTime |
| 331 | The Camera supports setting a \l{QCamera::manualExposureTime}{manual exposure Time}. |
| 332 | \value CustomFocusPoint |
| 333 | The Camera supports setting a \l{QCamera::customFocusPoint}{custom focus point}. |
| 334 | \value FocusDistance |
| 335 | The Camera supports setting the \l{focusDistance} property. |
| 336 | */ |
| 337 | |
| 338 | /*! |
| 339 | \qmlproperty Features QtMultimedia::Camera::supportedFeatures |
| 340 | Returns the features supported by this camera. |
| 341 | |
| 342 | \sa QCamera::Feature |
| 343 | */ |
| 344 | |
| 345 | /*! |
| 346 | \property QCamera::supportedFeatures |
| 347 | |
| 348 | Returns the features supported by this camera. |
| 349 | |
| 350 | \sa QCamera::Feature |
| 351 | */ |
| 352 | QCamera::Features QCamera::supportedFeatures() const |
| 353 | { |
| 354 | Q_D(const QCamera); |
| 355 | return d->control ? d->control->supportedFeatures() : QCamera::Features{}; |
| 356 | } |
| 357 | |
| 358 | /*! \qmlmethod void Camera::start() |
| 359 | |
| 360 | Starts the camera. |
| 361 | |
| 362 | Same as setting the active property to true. |
| 363 | |
| 364 | If the camera can't be started for some reason, the errorOccurred() signal is emitted. |
| 365 | */ |
| 366 | |
| 367 | /*! \fn void QCamera::start() |
| 368 | |
| 369 | Starts the camera. |
| 370 | |
| 371 | Same as setActive(true). |
| 372 | |
| 373 | If the camera can't be started for some reason, the errorOccurred() signal is emitted. |
| 374 | */ |
| 375 | |
| 376 | /*! \qmlmethod void Camera::stop() |
| 377 | |
| 378 | Stops the camera. |
| 379 | Same as setting the active property to false. |
| 380 | */ |
| 381 | |
| 382 | /*! \fn void QCamera::stop() |
| 383 | |
| 384 | Stops the camera. |
| 385 | Same as setActive(false). |
| 386 | */ |
| 387 | |
| 388 | /*! |
| 389 | Returns the capture session this camera is connected to, or |
| 390 | a nullptr if the camera is not connected to a capture session. |
| 391 | |
| 392 | use QMediaCaptureSession::setCamera() to connect the camera to |
| 393 | a session. |
| 394 | */ |
| 395 | QMediaCaptureSession *QCamera::captureSession() const |
| 396 | { |
| 397 | Q_D(const QCamera); |
| 398 | return d->captureSession; |
| 399 | } |
| 400 | |
| 401 | /*! |
| 402 | \internal |
| 403 | */ |
| 404 | void QCamera::setCaptureSession(QMediaCaptureSession *session) |
| 405 | { |
| 406 | Q_D(QCamera); |
| 407 | d->captureSession = session; |
| 408 | } |
| 409 | |
| 410 | /*! |
| 411 | \internal |
| 412 | */ |
| 413 | QPlatformCamera *QCamera::platformCamera() |
| 414 | { |
| 415 | Q_D(const QCamera); |
| 416 | return d->control; |
| 417 | } |
| 418 | |
| 419 | /*! \qmlproperty cameraDevice QtMultimedia::Camera::cameraDevice |
| 420 | |
| 421 | Gets or sets the currently active camera device. |
| 422 | |
| 423 | When switching camera devices, the QCamera's capabilities are updated. |
| 424 | Additionally, the QCamera's control properties (such as \l focusMode, |
| 425 | \l flashMode, \l focusDistance, \l zoomFactor) are updated as follows: |
| 426 | |
| 427 | \list |
| 428 | \li If a property is supported on the new device, the property value is applied to the |
| 429 | camera device. |
| 430 | \li If a property is supported but its range of valid values was changed, the property |
| 431 | is clamped to the new range and applied to the camera device. |
| 432 | \li If the new camera device does not support a property, the property value is reset |
| 433 | to default, and no changes are made to the camera device. |
| 434 | \endlist |
| 435 | */ |
| 436 | |
| 437 | /*! |
| 438 | \property QCamera::cameraDevice |
| 439 | |
| 440 | Returns the QCameraDevice object associated with this camera. |
| 441 | */ |
| 442 | QCameraDevice QCamera::cameraDevice() const |
| 443 | { |
| 444 | Q_D(const QCamera); |
| 445 | return d->cameraDevice; |
| 446 | } |
| 447 | |
| 448 | /*! |
| 449 | Connects the camera object to the physical camera device described by |
| 450 | \a cameraDevice. Using a default constructed QCameraDevice object as |
| 451 | \a cameraDevice will connect the camera to the system default camera device. |
| 452 | |
| 453 | When switching camera devices, the QCamera's capabilities are updated. |
| 454 | Additionally, the QCamera's control properties (such as \l focusMode, |
| 455 | \l flashMode, \l focusDistance, \l zoomFactor) are updated as follows: |
| 456 | |
| 457 | \list |
| 458 | \li If a property is supported on the new device, the property value is applied to the |
| 459 | camera device. |
| 460 | \li If a property is supported but its range of valid values was changed, the property |
| 461 | is clamped to the new range and applied to the camera device. |
| 462 | \li If the new camera device does not support a property, the property value is reset |
| 463 | to default, and no changes are made to the camera device. |
| 464 | \endlist |
| 465 | */ |
| 466 | void QCamera::setCameraDevice(const QCameraDevice &cameraDevice) |
| 467 | { |
| 468 | Q_D(QCamera); |
| 469 | auto dev = cameraDevice; |
| 470 | if (dev.isNull()) |
| 471 | dev = QMediaDevices::defaultVideoInput(); |
| 472 | if (d->cameraDevice == dev) |
| 473 | return; |
| 474 | d->cameraDevice = dev; |
| 475 | if (d->control) |
| 476 | d->control->setCamera(d->cameraDevice); |
| 477 | emit cameraDeviceChanged(); |
| 478 | setCameraFormat({}); |
| 479 | } |
| 480 | |
| 481 | /*! \qmlproperty cameraFormat QtMultimedia::Camera::cameraFormat |
| 482 | |
| 483 | Gets or sets the currently active camera format. |
| 484 | |
| 485 | \note When using the FFMPEG backend on an Android target device if you request |
| 486 | \b YUV420P format, you will receive either a fully planar 4:2:0 YUV420P or a |
| 487 | semi-planar NV12/NV21. This depends on the codec implemented by the device |
| 488 | OEM. |
| 489 | |
| 490 | \sa cameraDevice::videoFormats |
| 491 | */ |
| 492 | |
| 493 | /*! |
| 494 | \property QCamera::cameraFormat |
| 495 | |
| 496 | Returns the camera format currently used by the camera. |
| 497 | |
| 498 | \note When using the FFMPEG backend on an Android target device if you request |
| 499 | \b YUV420P format, you will receive either a fully planar 4:2:0 YUV420P or a |
| 500 | semi-planar NV12/NV21. This depends on the codec implemented by the device |
| 501 | OEM. |
| 502 | |
| 503 | \sa QCameraDevice::videoFormats |
| 504 | */ |
| 505 | QCameraFormat QCamera::cameraFormat() const |
| 506 | { |
| 507 | Q_D(const QCamera); |
| 508 | return d->cameraFormat; |
| 509 | } |
| 510 | |
| 511 | /*! |
| 512 | Tells the camera to use the format described by \a format. This can be used to define |
| 513 | a specific resolution and frame rate to be used for recording and image capture. |
| 514 | |
| 515 | \note When using the FFMPEG backend on an Android target device if you request |
| 516 | \b YUV420P format, you will receive either a fully planar 4:2:0 YUV420P or a |
| 517 | semi-planar NV12/NV21. This depends on the codec implemented by the device |
| 518 | OEM. |
| 519 | */ |
| 520 | void QCamera::setCameraFormat(const QCameraFormat &format) |
| 521 | { |
| 522 | Q_D(QCamera); |
| 523 | if (!d->control || !d->control->setCameraFormat(format)) |
| 524 | return; |
| 525 | |
| 526 | d->cameraFormat = format; |
| 527 | emit cameraFormatChanged(); |
| 528 | } |
| 529 | |
| 530 | /*! |
| 531 | \enum QCamera::Error |
| 532 | |
| 533 | This enum holds the last error code. |
| 534 | |
| 535 | \value NoError No errors have occurred. |
| 536 | \value CameraError An error has occurred. |
| 537 | */ |
| 538 | |
| 539 | /*! |
| 540 | \qmlsignal void Camera::errorOccurred(Camera::Error error, string errorString) |
| 541 | |
| 542 | This signal is emitted when error state changes to \a error. A description |
| 543 | of the error is provided as \a errorString. |
| 544 | */ |
| 545 | |
| 546 | /*! |
| 547 | \fn void QCamera::errorOccurred(QCamera::Error error, const QString &errorString) |
| 548 | |
| 549 | This signal is emitted when error state changes to \a error. A description |
| 550 | of the error is provided as \a errorString. |
| 551 | */ |
| 552 | |
| 553 | /*! |
| 554 | \qmlproperty enumeration Camera::focusMode |
| 555 | |
| 556 | This property holds the value that controls focus mode for the camera device. |
| 557 | In all autofocus modes, the camera device keeps focusing continuously. |
| 558 | |
| 559 | \note In automatic focusing modes and where supported, the \l focusPoint property provides |
| 560 | information and control over the area of the image that is being focused. |
| 561 | |
| 562 | \value Camera.FocusModeAuto Continuous auto focus mode. |
| 563 | \value Camera.FocusModeAutoNear Continuous auto focus, preferring objects near to |
| 564 | the camera. |
| 565 | \value Camera.FocusModeAutoFar Continuous auto focus, preferring objects far away |
| 566 | from the camera. |
| 567 | \value Camera.FocusModeHyperfocal Focus to hyperfocal distance, with the maximum |
| 568 | depth of field achieved. All objects at distances from half of this |
| 569 | distance out to infinity will be acceptably sharp. |
| 570 | \value Camera.FocusModeInfinity Focus strictly to infinity. |
| 571 | \value Camera.FocusModeManual The lens focus distance is set to a value specified by \l focusDistance. |
| 572 | |
| 573 | To check whether the camera device supports a particular focus mode, pass the corresponding |
| 574 | \c focusMode value to the \l isFocusModeSupported() function as a parameter. The function |
| 575 | returns \c false if the focus mode value is not supported. Assigning an unsupported mode to |
| 576 | this property has no effect. |
| 577 | |
| 578 | If you set the focusMode property to \c Camera.FocusModeManual, the lens |
| 579 | locks to the focus according to \l focusDistance. |
| 580 | |
| 581 | \sa isFocusModeSupported() |
| 582 | */ |
| 583 | |
| 584 | /*! |
| 585 | \property QCamera::focusMode |
| 586 | \brief the current camera focus mode. |
| 587 | |
| 588 | This property holds the value that controls focus mode for the camera device. |
| 589 | In all autofocus modes, the camera device keeps focusing continuously. |
| 590 | |
| 591 | To check whether the camera device supports a particular focus mode, pass the corresponding |
| 592 | \l FocusMode value to the \l isFocusModeSupported function as a parameter. The function |
| 593 | returns false if the focus mode value is not supported. Assigning an unsupported mode to |
| 594 | this property has no effect. |
| 595 | |
| 596 | If you set the focusMode property to \l QCamera::FocusModeManual, the lens |
| 597 | locks to the focus according to \l focusDistance. |
| 598 | |
| 599 | \sa isFocusModeSupported() |
| 600 | */ |
| 601 | QCamera::FocusMode QCamera::focusMode() const |
| 602 | { |
| 603 | Q_D(const QCamera); |
| 604 | return d->control ? d->control->focusMode() : QCamera::FocusModeAuto; |
| 605 | } |
| 606 | |
| 607 | /*! |
| 608 | \fn void QCamera::focusModeChanged() |
| 609 | |
| 610 | Signals when the focusMode changes. |
| 611 | */ |
| 612 | void QCamera::setFocusMode(QCamera::FocusMode mode) |
| 613 | { |
| 614 | Q_D(QCamera); |
| 615 | if (!d->control || d->control->focusMode() == mode) |
| 616 | return; |
| 617 | d->control->setFocusMode(mode); |
| 618 | } |
| 619 | |
| 620 | /*! |
| 621 | \qmlmethod bool Camera::isFocusModeSupported(FocusMode mode) |
| 622 | |
| 623 | Returns \c true if the focus \a mode is supported by the camera. |
| 624 | |
| 625 | If \l {focusMode}{Camera.FocusModeManual} is reported as supported, |
| 626 | the feature \l {supportedFeatures}{Camera.FocusDistance} is implied |
| 627 | to be supported as well. |
| 628 | */ |
| 629 | |
| 630 | /*! |
| 631 | Returns \c true if the focus \a mode is supported by the camera. |
| 632 | |
| 633 | If \l FocusModeManual is reported as supported, the feature |
| 634 | \l Feature::FocusDistance is implied to be supported as well. |
| 635 | */ |
| 636 | bool QCamera::isFocusModeSupported(FocusMode mode) const |
| 637 | { |
| 638 | Q_D(const QCamera); |
| 639 | return d->control ? d->control->isFocusModeSupported(mode) : false; |
| 640 | } |
| 641 | |
| 642 | /*! |
| 643 | \qmlproperty point QtMultimedia::Camera::focusPoint |
| 644 | Returns the point currently used by the auto focus system to focus onto. |
| 645 | */ |
| 646 | |
| 647 | /*! |
| 648 | \property QCamera::focusPoint |
| 649 | |
| 650 | Returns the point currently used by the auto focus system to focus onto. |
| 651 | */ |
| 652 | QPointF QCamera::focusPoint() const |
| 653 | { |
| 654 | Q_D(const QCamera); |
| 655 | return d->control ? d->control->focusPoint() : QPointF(-1., -1.); |
| 656 | |
| 657 | } |
| 658 | |
| 659 | /*! |
| 660 | \qmlproperty point QtMultimedia::Camera::customFocusPoint |
| 661 | |
| 662 | This property holds the position of custom focus point, in relative frame |
| 663 | coordinates. This means that QPointF(0,0) points to the top-left corner |
| 664 | of the frame, and QPointF(0.5,0.5) points to the center of the frame. |
| 665 | |
| 666 | Custom focus point is used only in \c FocusPointCustom focus mode. |
| 667 | |
| 668 | You can check whether custom focus points are supported by querying |
| 669 | supportedFeatures() with the Feature.CustomFocusPoint flag. |
| 670 | */ |
| 671 | |
| 672 | /*! |
| 673 | \property QCamera::customFocusPoint |
| 674 | |
| 675 | This property represents the position of the custom focus point, in relative frame coordinates: |
| 676 | QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center. |
| 677 | |
| 678 | The custom focus point property is used only in \c FocusPointCustom focus mode. |
| 679 | |
| 680 | You can check whether custom focus points are supported by querying |
| 681 | supportedFeatures() with the Feature.CustomFocusPoint flag. |
| 682 | */ |
| 683 | QPointF QCamera::customFocusPoint() const |
| 684 | { |
| 685 | Q_D(const QCamera); |
| 686 | return d->control ? d->control->customFocusPoint() : QPointF{-1., -1.}; |
| 687 | } |
| 688 | |
| 689 | void QCamera::setCustomFocusPoint(const QPointF &point) |
| 690 | { |
| 691 | Q_D(QCamera); |
| 692 | if (d->control) |
| 693 | d->control->setCustomFocusPoint(point); |
| 694 | } |
| 695 | |
| 696 | /*! |
| 697 | \qmlproperty real QtMultimedia::Camera::focusDistance |
| 698 | |
| 699 | This property defines the lens focus distance when the camera device works in |
| 700 | manual focus mode. Valid values range from 0 to 1, where 0 is the closest |
| 701 | possible focus distance, and 1 is the farthest. The farthest point is |
| 702 | typically at infinity, but this may not be the case for all devices. |
| 703 | |
| 704 | This property is applied to the device only when \l focusMode is set to |
| 705 | \l {focusMode}{Camera.FocusModeManual}, and \l supportedFeatures includes the |
| 706 | \c Camera.FocusDistance flag. |
| 707 | |
| 708 | If you assign a value to this property while \l focusMode is not |
| 709 | set to \c Camera.FocusModeManual, the property stores the value but does |
| 710 | not affect the device until \c Camera.FocusModeManual is active. |
| 711 | |
| 712 | Assigning a value outside the valid range [0, 1] has no effect on this property. |
| 713 | |
| 714 | If \l supportedFeatures does not include the \c Camera.FocusDistance flag, |
| 715 | any attempt to set this property is ignored. |
| 716 | |
| 717 | This property will not be updated by the camera when it is in an automatic focus mode. |
| 718 | |
| 719 | The default value is 1. |
| 720 | */ |
| 721 | |
| 722 | /*! |
| 723 | \property QCamera::focusDistance |
| 724 | |
| 725 | This property defines the lens focus distance when the camera device works in |
| 726 | manual focus mode. Valid values range from 0 to 1, where 0 is the closest |
| 727 | possible focus distance, and 1 is the farthest. The farthest point is |
| 728 | typically at infinity, but this may not be the case for all devices. |
| 729 | |
| 730 | This property is applied to the device only when \l focusMode is set to |
| 731 | \l FocusModeManual, and \l supportedFeatures includes the |
| 732 | \l Feature::FocusDistance flag. |
| 733 | |
| 734 | If you assign a value to this property while \l focusMode is not |
| 735 | set to \c QCamera::FocusModeManual, the property stores the value but does |
| 736 | not affect the device until \c QCamera::FocusModeManual is active. |
| 737 | |
| 738 | Assigning a value outside the valid range [0, 1] has no effect on this property. |
| 739 | |
| 740 | If \l supportedFeatures does not include the \l FocusDistance flag, |
| 741 | any attempt to set this property is ignored. |
| 742 | |
| 743 | This property will not be updated by the camera when it is in an automatic focus mode. |
| 744 | |
| 745 | The default value is 1. |
| 746 | */ |
| 747 | void QCamera::setFocusDistance(float distance) |
| 748 | { |
| 749 | if (!d_func()->control) |
| 750 | return; |
| 751 | d_func()->control->setFocusDistance(distance); |
| 752 | } |
| 753 | |
| 754 | float QCamera::focusDistance() const |
| 755 | { |
| 756 | if (d_func()->control) |
| 757 | return d_func()->control->focusDistance(); |
| 758 | return 0.f; |
| 759 | } |
| 760 | |
| 761 | /*! |
| 762 | \qmlproperty real QtMultimedia::Camera::maximumZoomFactor |
| 763 | |
| 764 | This property holds the maximum zoom factor supported. |
| 765 | |
| 766 | This will be \c 1.0 on cameras that do not support zooming. |
| 767 | */ |
| 768 | |
| 769 | |
| 770 | /*! |
| 771 | \property QCamera::maximumZoomFactor |
| 772 | |
| 773 | Returns the maximum zoom factor. |
| 774 | |
| 775 | This will be \c 1.0 on cameras that do not support zooming. |
| 776 | */ |
| 777 | |
| 778 | float QCamera::maximumZoomFactor() const |
| 779 | { |
| 780 | Q_D(const QCamera); |
| 781 | return d->control ? d->control->maxZoomFactor() : 1.f; |
| 782 | } |
| 783 | |
| 784 | /*! |
| 785 | \qmlproperty real QtMultimedia::Camera::minimumZoomFactor |
| 786 | |
| 787 | This property holds the minimum zoom factor supported. |
| 788 | |
| 789 | This will be \c 1.0 on cameras that do not support zooming. |
| 790 | */ |
| 791 | |
| 792 | /*! |
| 793 | \property QCamera::minimumZoomFactor |
| 794 | |
| 795 | Returns the minimum zoom factor. |
| 796 | |
| 797 | This will be \c 1.0 on cameras that do not support zooming. |
| 798 | */ |
| 799 | |
| 800 | float QCamera::minimumZoomFactor() const |
| 801 | { |
| 802 | Q_D(const QCamera); |
| 803 | return d->control ? d->control->minZoomFactor() : 1.f; |
| 804 | } |
| 805 | |
| 806 | /*! |
| 807 | \qmlproperty real QtMultimedia::Camera::zoomFactor |
| 808 | |
| 809 | Gets or sets the current zoom factor. Values will be clamped between |
| 810 | \l minimumZoomFactor and \l maximumZoomFactor. |
| 811 | */ |
| 812 | |
| 813 | /*! |
| 814 | \property QCamera::zoomFactor |
| 815 | \brief The current zoom factor. |
| 816 | |
| 817 | Gets or sets the current zoom factor. Values will be clamped between |
| 818 | \l minimumZoomFactor and \l maximumZoomFactor. |
| 819 | */ |
| 820 | float QCamera::zoomFactor() const |
| 821 | { |
| 822 | Q_D(const QCamera); |
| 823 | return d->control ? d->control->zoomFactor() : 1.f; |
| 824 | } |
| 825 | /*! |
| 826 | Zooms to a zoom factor \a factor at a rate of 1 factor per second. |
| 827 | */ |
| 828 | void QCamera::setZoomFactor(float factor) |
| 829 | { |
| 830 | zoomTo(zoom: factor, rate: 0.f); |
| 831 | } |
| 832 | |
| 833 | /*! |
| 834 | \qmlmethod void QtMultimedia::Camera::zoomTo(factor, rate) |
| 835 | |
| 836 | Zooms to a zoom factor \a factor using \a rate. |
| 837 | |
| 838 | The \a rate is specified in powers of two per second. At a rate of 1 |
| 839 | it would take 2 seconds to go from a zoom factor of 1 to 4. |
| 840 | |
| 841 | \note Using a specific rate is not supported on all cameras. If not supported, |
| 842 | zooming will happen as fast as possible. |
| 843 | */ |
| 844 | |
| 845 | /*! |
| 846 | Zooms to a zoom factor \a factor using \a rate. |
| 847 | |
| 848 | The \a rate is specified in powers of two per second. At a rate of 1 |
| 849 | it would take 2 seconds to go from a zoom factor of 1 to 4. |
| 850 | |
| 851 | \note Using a specific rate is not supported on all cameras. If not supported, |
| 852 | zooming will happen as fast as possible. |
| 853 | */ |
| 854 | void QCamera::zoomTo(float factor, float rate) |
| 855 | { |
| 856 | Q_ASSERT(rate >= 0.f); |
| 857 | if (rate < 0.f) |
| 858 | rate = 0.f; |
| 859 | |
| 860 | Q_D(QCamera); |
| 861 | if (!d->control) |
| 862 | return; |
| 863 | factor = qBound(min: d->control->minZoomFactor(), val: factor, max: d->control->maxZoomFactor()); |
| 864 | d->control->zoomTo(factor, rate); |
| 865 | } |
| 866 | |
| 867 | /*! |
| 868 | \enum QCamera::FocusMode |
| 869 | |
| 870 | \value FocusModeAuto Continuous auto focus mode. |
| 871 | \value FocusModeAutoNear Continuous auto focus mode on near objects. |
| 872 | \value FocusModeAutoFar Continuous auto focus mode on objects far away. |
| 873 | \value FocusModeHyperfocal Focus to hyperfocal distance, with the maximum depth of field achieved. |
| 874 | All objects at distances from half of this |
| 875 | distance out to infinity will be acceptably sharp. |
| 876 | \value FocusModeInfinity Focus strictly to infinity. |
| 877 | \value FocusModeManual Camera lens focus distance is locked according to \l focusDistance. |
| 878 | */ |
| 879 | |
| 880 | /*! |
| 881 | \qmlproperty enumeration QtMultimedia::Camera::flashMode |
| 882 | |
| 883 | Gets or sets a certain flash mode if the camera has a flash. |
| 884 | |
| 885 | Assigning an unsupported mode to this property has no effect. |
| 886 | |
| 887 | This property only has an effect when capturing images using |
| 888 | \l ImageCapture |
| 889 | |
| 890 | \value Camera.FlashOff Flash is Off. |
| 891 | \value Camera.FlashOn Flash is On. |
| 892 | \value Camera.FlashAuto Automatic flash. |
| 893 | |
| 894 | \sa isFlashModeSupported, isFlashReady |
| 895 | */ |
| 896 | |
| 897 | /*! |
| 898 | \property QCamera::flashMode |
| 899 | \brief The flash mode being used. |
| 900 | |
| 901 | Enables a certain flash mode if the camera has a flash. |
| 902 | |
| 903 | Assigning an unsupported mode to this property has no effect. |
| 904 | |
| 905 | This property only has an effect when capturing images using |
| 906 | \l QImageCapture |
| 907 | |
| 908 | \sa QCamera::FlashMode, QCamera::isFlashModeSupported, QCamera::isFlashReady |
| 909 | */ |
| 910 | QCamera::FlashMode QCamera::flashMode() const |
| 911 | { |
| 912 | Q_D(const QCamera); |
| 913 | return d->control ? d->control->flashMode() : QCamera::FlashOff; |
| 914 | } |
| 915 | |
| 916 | void QCamera::setFlashMode(QCamera::FlashMode mode) |
| 917 | { |
| 918 | Q_D(QCamera); |
| 919 | if (d->control) |
| 920 | d->control->setFlashMode(mode); |
| 921 | } |
| 922 | |
| 923 | /*! |
| 924 | \qmlmethod bool QtMultimedia::Camera::isFlashModeSupported(FlashMode mode) |
| 925 | |
| 926 | Returns true if the flash \a mode is supported. |
| 927 | */ |
| 928 | |
| 929 | /*! |
| 930 | Returns true if the flash \a mode is supported. |
| 931 | */ |
| 932 | bool QCamera::isFlashModeSupported(QCamera::FlashMode mode) const |
| 933 | { |
| 934 | Q_D(const QCamera); |
| 935 | return d->control ? d->control->isFlashModeSupported(mode) : (mode == FlashOff); |
| 936 | } |
| 937 | |
| 938 | /*! |
| 939 | \qmlmethod bool QtMultimedia::Camera::isFlashReady() |
| 940 | |
| 941 | Returns true if flash is charged. |
| 942 | */ |
| 943 | |
| 944 | /*! |
| 945 | Returns true if flash is charged. |
| 946 | */ |
| 947 | bool QCamera::isFlashReady() const |
| 948 | { |
| 949 | Q_D(const QCamera); |
| 950 | return d->control ? d->control->isFlashReady() : false; |
| 951 | } |
| 952 | |
| 953 | /*! |
| 954 | \qmlproperty Camera::TorchMode Camera::torchMode |
| 955 | |
| 956 | Gets or sets the torch mode being used. |
| 957 | |
| 958 | A torch is a continuous source of light. It can be used during video recording in |
| 959 | low light conditions. Enabling torch mode will usually override any currently set |
| 960 | flash mode. |
| 961 | |
| 962 | \sa QCamera::TorchMode, Camera::isTorchModeSupported(), Camera::flashMode |
| 963 | */ |
| 964 | |
| 965 | /*! |
| 966 | \property QCamera::torchMode |
| 967 | \brief The torch mode being used. |
| 968 | |
| 969 | A torch is a continuous source of light. It can be used during video recording in |
| 970 | low light conditions. Enabling torch mode will usually override any currently set |
| 971 | flash mode. |
| 972 | |
| 973 | \sa QCamera::TorchMode, QCamera::isTorchModeSupported, QCamera::flashMode |
| 974 | */ |
| 975 | QCamera::TorchMode QCamera::torchMode() const |
| 976 | { |
| 977 | Q_D(const QCamera); |
| 978 | return d->control ? d->control->torchMode() : TorchOff; |
| 979 | } |
| 980 | |
| 981 | void QCamera::setTorchMode(QCamera::TorchMode mode) |
| 982 | { |
| 983 | Q_D(QCamera); |
| 984 | if (d->control) |
| 985 | d->control->setTorchMode(mode); |
| 986 | } |
| 987 | |
| 988 | /*! |
| 989 | \qmlmethod bool QtMultimedia::Camera::isTorchModeSupported(TorchMode mode) |
| 990 | |
| 991 | Returns true if the torch \a mode is supported. |
| 992 | */ |
| 993 | |
| 994 | /*! |
| 995 | Returns true if the torch \a mode is supported. |
| 996 | */ |
| 997 | bool QCamera::isTorchModeSupported(QCamera::TorchMode mode) const |
| 998 | { |
| 999 | Q_D(const QCamera); |
| 1000 | return d->control ? d->control->isTorchModeSupported(mode) : (mode == TorchOff); |
| 1001 | } |
| 1002 | |
| 1003 | /*! |
| 1004 | \qmlproperty ExposureMode QtMultimedia::Camera::exposureMode |
| 1005 | \brief The exposure mode being used. |
| 1006 | |
| 1007 | \sa QCamera::ExposureMode, Camera::isExposureModeSupported() |
| 1008 | */ |
| 1009 | |
| 1010 | /*! |
| 1011 | \property QCamera::exposureMode |
| 1012 | \brief The exposure mode being used. |
| 1013 | |
| 1014 | \sa QCamera::isExposureModeSupported |
| 1015 | */ |
| 1016 | QCamera::ExposureMode QCamera::exposureMode() const |
| 1017 | { |
| 1018 | Q_D(const QCamera); |
| 1019 | return d->control ? d->control->exposureMode() : QCamera::ExposureAuto; |
| 1020 | } |
| 1021 | |
| 1022 | void QCamera::setExposureMode(QCamera::ExposureMode mode) |
| 1023 | { |
| 1024 | Q_D(QCamera); |
| 1025 | if (d->control) |
| 1026 | d->control->setExposureMode(mode); |
| 1027 | } |
| 1028 | |
| 1029 | /*! |
| 1030 | \qmlmethod bool QtMultimedia::Camera::isExposureModeSupported(ExposureMode mode) |
| 1031 | |
| 1032 | Returns true if the exposure \a mode is supported. |
| 1033 | */ |
| 1034 | |
| 1035 | /*! |
| 1036 | Returns true if the exposure \a mode is supported. |
| 1037 | */ |
| 1038 | bool QCamera::isExposureModeSupported(QCamera::ExposureMode mode) const |
| 1039 | { |
| 1040 | Q_D(const QCamera); |
| 1041 | return d->control && d->control->isExposureModeSupported(mode); |
| 1042 | } |
| 1043 | |
| 1044 | /*! |
| 1045 | \qmlproperty real QtMultimedia::Camera::exposureCompensation |
| 1046 | |
| 1047 | Gets or sets the exposure compensation in EV units. |
| 1048 | |
| 1049 | Exposure compensation property allows to adjust the automatically calculated |
| 1050 | exposure. |
| 1051 | */ |
| 1052 | |
| 1053 | /*! |
| 1054 | \property QCamera::exposureCompensation |
| 1055 | \brief Exposure compensation in EV units. |
| 1056 | |
| 1057 | Exposure compensation property allows to adjust the automatically calculated |
| 1058 | exposure. |
| 1059 | */ |
| 1060 | float QCamera::exposureCompensation() const |
| 1061 | { |
| 1062 | Q_D(const QCamera); |
| 1063 | return d->control ? d->control->exposureCompensation() : 0.f; |
| 1064 | } |
| 1065 | |
| 1066 | void QCamera::setExposureCompensation(float ev) |
| 1067 | { |
| 1068 | Q_D(QCamera); |
| 1069 | if (d->control) |
| 1070 | d->control->setExposureCompensation(ev); |
| 1071 | } |
| 1072 | |
| 1073 | /*! |
| 1074 | \qmlproperty int QtMultimedia::Camera::isoSensitivity |
| 1075 | |
| 1076 | Describes the ISO sensitivity currently used by the camera. |
| 1077 | |
| 1078 | */ |
| 1079 | |
| 1080 | /*! |
| 1081 | \property QCamera::isoSensitivity |
| 1082 | \brief The sensor ISO sensitivity. |
| 1083 | |
| 1084 | Describes the ISO sensitivity currently used by the camera. |
| 1085 | |
| 1086 | \sa setAutoIsoSensitivity(), setManualIsoSensitivity() |
| 1087 | */ |
| 1088 | int QCamera::isoSensitivity() const |
| 1089 | { |
| 1090 | Q_D(const QCamera); |
| 1091 | return d->control ? d->control->isoSensitivity() : -1; |
| 1092 | } |
| 1093 | |
| 1094 | /*! |
| 1095 | \qmlproperty int QtMultimedia::Camera::manualIsoSensitivity |
| 1096 | |
| 1097 | Describes a manually set ISO sensitivity |
| 1098 | |
| 1099 | Setting this property to -1 (the default), implies that the camera |
| 1100 | automatically adjusts the ISO sensitivity. |
| 1101 | */ |
| 1102 | |
| 1103 | /*! |
| 1104 | \property QCamera::manualIsoSensitivity |
| 1105 | \brief Describes a manually set ISO sensitivity |
| 1106 | |
| 1107 | Setting this property to -1 (the default), implies that the camera |
| 1108 | automatically adjusts the ISO sensitivity. |
| 1109 | */ |
| 1110 | void QCamera::setManualIsoSensitivity(int iso) |
| 1111 | { |
| 1112 | Q_D(QCamera); |
| 1113 | if (iso <= 0) |
| 1114 | iso = -1; |
| 1115 | if (d->control) |
| 1116 | d->control->setManualIsoSensitivity(iso); |
| 1117 | } |
| 1118 | |
| 1119 | int QCamera::manualIsoSensitivity() const |
| 1120 | { |
| 1121 | Q_D(const QCamera); |
| 1122 | return d->control ? d->control->manualIsoSensitivity() : 100; |
| 1123 | } |
| 1124 | |
| 1125 | /*! |
| 1126 | \fn QCamera::setAutoIsoSensitivity() |
| 1127 | Turn on auto sensitivity |
| 1128 | */ |
| 1129 | |
| 1130 | void QCamera::setAutoIsoSensitivity() |
| 1131 | { |
| 1132 | Q_D(QCamera); |
| 1133 | if (d->control) |
| 1134 | d->control->setManualIsoSensitivity(-1); |
| 1135 | } |
| 1136 | |
| 1137 | /*! |
| 1138 | Returns the minimum ISO sensitivity supported by the camera. |
| 1139 | */ |
| 1140 | int QCamera::minimumIsoSensitivity() const |
| 1141 | { |
| 1142 | Q_D(const QCamera); |
| 1143 | return d->control ? d->control->minIso() : -1; |
| 1144 | } |
| 1145 | |
| 1146 | /*! |
| 1147 | Returns the maximum ISO sensitivity supported by the camera. |
| 1148 | */ |
| 1149 | int QCamera::maximumIsoSensitivity() const |
| 1150 | { |
| 1151 | Q_D(const QCamera); |
| 1152 | return d->control ? d->control->maxIso() : -1; |
| 1153 | } |
| 1154 | |
| 1155 | /*! |
| 1156 | The minimal exposure time in seconds. |
| 1157 | */ |
| 1158 | float QCamera::minimumExposureTime() const |
| 1159 | { |
| 1160 | Q_D(const QCamera); |
| 1161 | return d->control ? d->control->minExposureTime() : -1.f; |
| 1162 | } |
| 1163 | |
| 1164 | /*! |
| 1165 | The maximal exposure time in seconds. |
| 1166 | */ |
| 1167 | float QCamera::maximumExposureTime() const |
| 1168 | { |
| 1169 | Q_D(const QCamera); |
| 1170 | return d->control ? d->control->maxExposureTime() : -1.f; |
| 1171 | } |
| 1172 | |
| 1173 | /*! |
| 1174 | \qmlproperty real QtMultimedia::Camera::exposureTime |
| 1175 | Returns the Camera's exposure time in seconds. |
| 1176 | |
| 1177 | \sa manualExposureTime |
| 1178 | */ |
| 1179 | |
| 1180 | /*! |
| 1181 | \property QCamera::exposureTime |
| 1182 | \brief Camera's exposure time in seconds. |
| 1183 | |
| 1184 | \sa minimumExposureTime(), maximumExposureTime(), setManualExposureTime() |
| 1185 | */ |
| 1186 | |
| 1187 | /*! |
| 1188 | \fn QCamera::exposureTimeChanged(float speed) |
| 1189 | |
| 1190 | Signals that a camera's exposure \a speed has changed. |
| 1191 | */ |
| 1192 | |
| 1193 | /*! |
| 1194 | Returns the current exposure time in seconds. |
| 1195 | */ |
| 1196 | |
| 1197 | float QCamera::exposureTime() const |
| 1198 | { |
| 1199 | Q_D(const QCamera); |
| 1200 | return d->control ? d->control->exposureTime() : -1; |
| 1201 | } |
| 1202 | |
| 1203 | /*! |
| 1204 | \qmlproperty real QtMultimedia::Camera::manualExposureTime |
| 1205 | |
| 1206 | Gets or sets a manual exposure time. |
| 1207 | |
| 1208 | Setting this property to -1 (the default) means that the camera |
| 1209 | automatically determines the exposure time. |
| 1210 | */ |
| 1211 | |
| 1212 | /*! |
| 1213 | \property QCamera::manualExposureTime |
| 1214 | |
| 1215 | Set the manual exposure time to \a seconds |
| 1216 | */ |
| 1217 | |
| 1218 | void QCamera::setManualExposureTime(float seconds) |
| 1219 | { |
| 1220 | Q_D(QCamera); |
| 1221 | if (d->control) |
| 1222 | d->control->setManualExposureTime(seconds); |
| 1223 | } |
| 1224 | |
| 1225 | /*! |
| 1226 | Returns the manual exposure time in seconds, or -1 |
| 1227 | if the camera is using automatic exposure times. |
| 1228 | */ |
| 1229 | float QCamera::manualExposureTime() const |
| 1230 | { |
| 1231 | Q_D(const QCamera); |
| 1232 | return d->control ? d->control->manualExposureTime() : -1; |
| 1233 | } |
| 1234 | |
| 1235 | /*! |
| 1236 | Use automatically calculated exposure time |
| 1237 | */ |
| 1238 | void QCamera::setAutoExposureTime() |
| 1239 | { |
| 1240 | Q_D(QCamera); |
| 1241 | if (d->control) |
| 1242 | d->control->setManualExposureTime(-1); |
| 1243 | } |
| 1244 | |
| 1245 | |
| 1246 | /*! |
| 1247 | \enum QCamera::FlashMode |
| 1248 | |
| 1249 | \value FlashOff Flash is Off. |
| 1250 | \value FlashOn Flash is On. |
| 1251 | \value FlashAuto Automatic flash. |
| 1252 | */ |
| 1253 | |
| 1254 | /*! |
| 1255 | \enum QCamera::TorchMode |
| 1256 | |
| 1257 | \value TorchOff Torch is Off. |
| 1258 | \value TorchOn Torch is On. |
| 1259 | \value TorchAuto Automatic torch. |
| 1260 | */ |
| 1261 | |
| 1262 | /*! |
| 1263 | \enum QCamera::ExposureMode |
| 1264 | |
| 1265 | \value ExposureAuto Automatic mode. |
| 1266 | \value ExposureManual Manual mode. |
| 1267 | \value ExposurePortrait Portrait exposure mode. |
| 1268 | \value ExposureNight Night mode. |
| 1269 | \value ExposureSports Spots exposure mode. |
| 1270 | \value ExposureSnow Snow exposure mode. |
| 1271 | \value ExposureBeach Beach exposure mode. |
| 1272 | \value ExposureAction Action mode. Since 5.5 |
| 1273 | \value ExposureLandscape Landscape mode. Since 5.5 |
| 1274 | \value ExposureNightPortrait Night portrait mode. Since 5.5 |
| 1275 | \value ExposureTheatre Theatre mode. Since 5.5 |
| 1276 | \value ExposureSunset Sunset mode. Since 5.5 |
| 1277 | \value ExposureSteadyPhoto Steady photo mode. Since 5.5 |
| 1278 | \value ExposureFireworks Fireworks mode. Since 5.5 |
| 1279 | \value ExposureParty Party mode. Since 5.5 |
| 1280 | \value ExposureCandlelight Candlelight mode. Since 5.5 |
| 1281 | \value ExposureBarcode Barcode mode. Since 5.5 |
| 1282 | */ |
| 1283 | |
| 1284 | /*! |
| 1285 | \qmlproperty bool QtMultimedia::Camera::flashReady |
| 1286 | |
| 1287 | Indicates if the flash is charged and ready to use. |
| 1288 | */ |
| 1289 | |
| 1290 | /*! |
| 1291 | \property QCamera::flashReady |
| 1292 | \brief Indicates if the flash is charged and ready to use. |
| 1293 | */ |
| 1294 | |
| 1295 | /*! |
| 1296 | \fn void QCamera::flashReady(bool ready) |
| 1297 | |
| 1298 | Signal the flash \a ready status has changed. |
| 1299 | */ |
| 1300 | |
| 1301 | /*! |
| 1302 | \fn void QCamera::isoSensitivityChanged(int value) |
| 1303 | |
| 1304 | Signal emitted when sensitivity changes to \a value. |
| 1305 | */ |
| 1306 | |
| 1307 | /*! |
| 1308 | \fn void QCamera::exposureCompensationChanged(float value) |
| 1309 | |
| 1310 | Signal emitted when the exposure compensation changes to \a value. |
| 1311 | */ |
| 1312 | |
| 1313 | |
| 1314 | /*! |
| 1315 | \qmlproperty WhiteBalanceMode QtMultimedia::Camera::whiteBalanceMode |
| 1316 | |
| 1317 | Gets or sets the white balance mode being used. |
| 1318 | |
| 1319 | \sa QCamera::WhiteBalanceMode |
| 1320 | */ |
| 1321 | |
| 1322 | /*! |
| 1323 | \property QCamera::whiteBalanceMode |
| 1324 | |
| 1325 | Returns the white balance mode being used. |
| 1326 | */ |
| 1327 | QCamera::WhiteBalanceMode QCamera::whiteBalanceMode() const |
| 1328 | { |
| 1329 | Q_D(const QCamera); |
| 1330 | return d->control ? d->control->whiteBalanceMode() : QCamera::WhiteBalanceAuto; |
| 1331 | } |
| 1332 | |
| 1333 | /*! |
| 1334 | Sets the white balance to \a mode. |
| 1335 | */ |
| 1336 | void QCamera::setWhiteBalanceMode(QCamera::WhiteBalanceMode mode) |
| 1337 | { |
| 1338 | Q_D(QCamera); |
| 1339 | if (!d->control) |
| 1340 | return; |
| 1341 | if (!d->control->isWhiteBalanceModeSupported(mode)) |
| 1342 | return; |
| 1343 | d->control->setWhiteBalanceMode(mode); |
| 1344 | if (mode == QCamera::WhiteBalanceManual) |
| 1345 | d->control->setColorTemperature(5600); |
| 1346 | } |
| 1347 | |
| 1348 | /*! |
| 1349 | \qmlmethod bool QtMultimedia::Camera::isWhiteBalanceModeSupported(WhiteBalanceMode mode) |
| 1350 | |
| 1351 | Returns true if the white balance \a mode is supported. |
| 1352 | */ |
| 1353 | |
| 1354 | /*! |
| 1355 | Returns true if the white balance \a mode is supported. |
| 1356 | */ |
| 1357 | bool QCamera::isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const |
| 1358 | { |
| 1359 | Q_D(const QCamera); |
| 1360 | return d->control && d->control->isWhiteBalanceModeSupported(mode); |
| 1361 | } |
| 1362 | |
| 1363 | /*! |
| 1364 | \qmlmethod QtMultimedia::Camera::colorTemperature |
| 1365 | |
| 1366 | Gets or sets the current color temperature. |
| 1367 | |
| 1368 | Setting a color temperature will only have an effect if WhiteBalanceManual is |
| 1369 | supported. In this case, setting a temperature greater 0 will automatically set the |
| 1370 | white balance mode to WhiteBalanceManual. Setting the temperature to 0 will reset |
| 1371 | the white balance mode to WhiteBalanceAuto. |
| 1372 | */ |
| 1373 | |
| 1374 | /*! |
| 1375 | \property QCamera::colorTemperature |
| 1376 | |
| 1377 | Returns the current color temperature if the |
| 1378 | current white balance mode is \c WhiteBalanceManual. For other modes the |
| 1379 | return value is undefined. |
| 1380 | */ |
| 1381 | int QCamera::colorTemperature() const |
| 1382 | { |
| 1383 | Q_D(const QCamera); |
| 1384 | return d->control ? d->control->colorTemperature() : 0; |
| 1385 | } |
| 1386 | |
| 1387 | /*! |
| 1388 | Sets manual white balance to \a colorTemperature. This is used |
| 1389 | when whiteBalanceMode() is set to \c WhiteBalanceManual. The units are Kelvin. |
| 1390 | |
| 1391 | Setting a color temperature will only have an effect if WhiteBalanceManual is |
| 1392 | supported. In this case, setting a temperature greater 0 will automatically set the |
| 1393 | white balance mode to WhiteBalanceManual. Setting the temperature to 0 will reset |
| 1394 | the white balance mode to WhiteBalanceAuto. |
| 1395 | */ |
| 1396 | |
| 1397 | void QCamera::setColorTemperature(int colorTemperature) |
| 1398 | { |
| 1399 | Q_D(QCamera); |
| 1400 | if (!d->control) |
| 1401 | return; |
| 1402 | if (colorTemperature < 0) |
| 1403 | colorTemperature = 0; |
| 1404 | if (colorTemperature == 0) { |
| 1405 | d->control->setWhiteBalanceMode(WhiteBalanceAuto); |
| 1406 | } else if (!isWhiteBalanceModeSupported(mode: WhiteBalanceManual)) { |
| 1407 | return; |
| 1408 | } else { |
| 1409 | d->control->setWhiteBalanceMode(WhiteBalanceManual); |
| 1410 | } |
| 1411 | d->control->setColorTemperature(colorTemperature); |
| 1412 | } |
| 1413 | |
| 1414 | /*! |
| 1415 | \enum QCamera::WhiteBalanceMode |
| 1416 | |
| 1417 | \value WhiteBalanceAuto Auto white balance mode. |
| 1418 | \value WhiteBalanceManual Manual white balance. In this mode the white |
| 1419 | balance should be set with setColorTemperature() |
| 1420 | \value WhiteBalanceSunlight Sunlight white balance mode. |
| 1421 | \value WhiteBalanceCloudy Cloudy white balance mode. |
| 1422 | \value WhiteBalanceShade Shade white balance mode. |
| 1423 | \value WhiteBalanceTungsten Tungsten (incandescent) white balance mode. |
| 1424 | \value WhiteBalanceFluorescent Fluorescent white balance mode. |
| 1425 | \value WhiteBalanceFlash Flash white balance mode. |
| 1426 | \value WhiteBalanceSunset Sunset white balance mode. |
| 1427 | */ |
| 1428 | |
| 1429 | /*! |
| 1430 | \fn void QCamera::brightnessChanged() |
| 1431 | \internal |
| 1432 | */ |
| 1433 | /*! |
| 1434 | \fn void QCamera::contrastChanged() |
| 1435 | \internal |
| 1436 | */ |
| 1437 | /*! |
| 1438 | \fn void QCamera::hueChanged() |
| 1439 | \internal |
| 1440 | */ |
| 1441 | /*! |
| 1442 | \fn void QCamera::saturationChanged() |
| 1443 | \internal |
| 1444 | */ |
| 1445 | QT_END_NAMESPACE |
| 1446 | |
| 1447 | #include "moc_qcamera.cpp" |
| 1448 | |