diff options
Diffstat (limited to 'experimental/Camera/camerautils')
-rw-r--r-- | experimental/Camera/camerautils/camerautils.cpp | 189 | ||||
-rw-r--r-- | experimental/Camera/camerautils/camerautils.h | 87 | ||||
-rw-r--r-- | experimental/Camera/camerautils/camerautils.pro | 19 | ||||
-rw-r--r-- | experimental/Camera/camerautils/plugin.cpp | 60 | ||||
-rw-r--r-- | experimental/Camera/camerautils/qmldir | 2 |
5 files changed, 0 insertions, 357 deletions
diff --git a/experimental/Camera/camerautils/camerautils.cpp b/experimental/Camera/camerautils/camerautils.cpp deleted file mode 100644 index 608bfaa..0000000 --- a/experimental/Camera/camerautils/camerautils.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include "camerautils.h" - -#include <QCamera> -#include <QCameraImageCapture> -#include <QCameraImageProcessing> -#include <QCameraExposure> -#include <QCameraFocus> -#include <QMediaRecorder> - -static QList<CameraSettingsValue*> g_commonResolutions; -static QList<CameraSettingsValue*> g_commonVideoResolutions; -static QList<CameraSettingsValue*> g_whiteBalanceModes; -static QList<CameraSettingsValue*> g_sceneModes; -static QList<CameraSettingsValue*> g_flashModes; -static QList<CameraSettingsValue*> g_focusModes; - -QDebug operator<<(QDebug dbg, const CameraSettingsValue &r) { - dbg.nospace() << "CameraSettingsValue(" << r.name() << ", " << r.value() << ')'; - return dbg.space(); -} - -CameraUtils::CameraUtils(QObject *parent) - : QObject(parent) - , m_camera(0) -{ - if (g_commonResolutions.isEmpty()) { - g_commonResolutions << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240)) - << new CameraSettingsValue(QStringLiteral("0.3M"), QSize(640, 480)) - << new CameraSettingsValue(QStringLiteral("0.8M"), QSize(1024, 768)) - << new CameraSettingsValue(QStringLiteral("1.2M"), QSize(1280, 960)) - << new CameraSettingsValue(QStringLiteral("2M"), QSize(1600, 1200)) - << new CameraSettingsValue(QStringLiteral("5M"), QSize(2560, 1920)) - << new CameraSettingsValue(QStringLiteral("8M"), QSize(3264, 2448)); - - g_commonVideoResolutions << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1080)) - << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1088)) - << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1080)) - << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1088)) - << new CameraSettingsValue(QStringLiteral("720p (16:9)"), QSize(1280, 720)) - << new CameraSettingsValue(QStringLiteral("720p (4:3)"), QSize(960, 720)) - << new CameraSettingsValue(QStringLiteral("480p (16:9)"), QSize(720, 480)) - << new CameraSettingsValue(QStringLiteral("480p (4:3)"), QSize(640, 480)) - << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240)); - - g_whiteBalanceModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraImageProcessing::WhiteBalanceAuto) - << new CameraSettingsValue(QStringLiteral("Manual"), QCameraImageProcessing::WhiteBalanceManual) - << new CameraSettingsValue(QStringLiteral("Sunlight"), QCameraImageProcessing::WhiteBalanceSunlight) - << new CameraSettingsValue(QStringLiteral("Cloudy"), QCameraImageProcessing::WhiteBalanceCloudy) - << new CameraSettingsValue(QStringLiteral("Shade"), QCameraImageProcessing::WhiteBalanceShade) - << new CameraSettingsValue(QStringLiteral("Tungsten"), QCameraImageProcessing::WhiteBalanceTungsten) - << new CameraSettingsValue(QStringLiteral("Fluorescent"), QCameraImageProcessing::WhiteBalanceFluorescent) - << new CameraSettingsValue(QStringLiteral("Flash"), QCameraImageProcessing::WhiteBalanceFlash) - << new CameraSettingsValue(QStringLiteral("Sunset"), QCameraImageProcessing::WhiteBalanceSunset); - - g_sceneModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::ExposureAuto) - << new CameraSettingsValue(QStringLiteral("Manual"), QCameraExposure::ExposureManual) - << new CameraSettingsValue(QStringLiteral("Portrait"), QCameraExposure::ExposurePortrait) - << new CameraSettingsValue(QStringLiteral("Night"), QCameraExposure::ExposureNight) - << new CameraSettingsValue(QStringLiteral("Backlight"), QCameraExposure::ExposureBacklight) - << new CameraSettingsValue(QStringLiteral("Spotlight"), QCameraExposure::ExposureSpotlight) - << new CameraSettingsValue(QStringLiteral("Sports"), QCameraExposure::ExposureSports) - << new CameraSettingsValue(QStringLiteral("Snow"), QCameraExposure::ExposureSnow) - << new CameraSettingsValue(QStringLiteral("Beach"), QCameraExposure::ExposureBeach) - << new CameraSettingsValue(QStringLiteral("Large Aperture"), QCameraExposure::ExposureLargeAperture) - << new CameraSettingsValue(QStringLiteral("Small Aperture"), QCameraExposure::ExposureSmallAperture); - - g_flashModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::FlashAuto) - << new CameraSettingsValue(QStringLiteral("Off"), QCameraExposure::FlashOff) - << new CameraSettingsValue(QStringLiteral("On"), QCameraExposure::FlashOn) - << new CameraSettingsValue(QStringLiteral("Red-Eye"), QCameraExposure::FlashRedEyeReduction) - << new CameraSettingsValue(QStringLiteral("Torch"), QCameraExposure::FlashVideoLight); - - g_focusModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraFocus::AutoFocus) - << new CameraSettingsValue(QStringLiteral("Continuous"), QCameraFocus::ContinuousFocus) - << new CameraSettingsValue(QStringLiteral("Hyperfocal"), QCameraFocus::HyperfocalFocus) - << new CameraSettingsValue(QStringLiteral("Infinity"), QCameraFocus::InfinityFocus) - << new CameraSettingsValue(QStringLiteral("Macro"), QCameraFocus::MacroFocus) - << new CameraSettingsValue(QStringLiteral("Off"), QCameraFocus::ManualFocus); - } - -} - -CameraUtils::~CameraUtils() -{ -} - -void CameraUtils::init() -{ - m_camera = new QCamera; - connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); - connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(onError())); - m_camera->load(); -} - -void CameraUtils::setCamera(QObject *obj) -{ - QObject *mediaObject = qvariant_cast<QObject*>(obj->property("mediaObject")); - if (!mediaObject) - return; - - m_camera = qobject_cast<QCamera*>(mediaObject); - if (!m_camera) - return; - - if (m_camera->status() >= QCamera::LoadedStatus) - onCameraStatusChanged(); - else - connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); -} - -void CameraUtils::onError() -{ - if (m_camera && m_camera->status() == QCamera::UnavailableStatus) { - delete m_camera; - m_camera = 0; - - emit done(); - } -} - -void CameraUtils::onCameraStatusChanged() -{ - if (!m_camera || m_camera->status() < QCamera::LoadedStatus) - return; - - disconnect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); - - QCameraImageCapture *imageCapture = new QCameraImageCapture(m_camera); - QCameraImageProcessing *imageProc = m_camera->imageProcessing(); - QCameraExposure *exposure = m_camera->exposure(); - QCameraFocus *focus = m_camera->focus(); - QMediaRecorder rec(m_camera); - - // Supported image resolutions - QList<QSize> resolutions = imageCapture->supportedResolutions(); - for (int i = resolutions.size() - 1; i >= 0; --i) { - QSize reso = resolutions.at(i); - int mp = reso.width() * reso.height(); - CameraSettingsValue *r = new CameraSettingsValue(QString::number(mp / double(1000000), 'f', 1) + QLatin1String("M"), reso); - m_supportedResolutions.append(r); - } - - // Supported video resolutions - QList<QSize> suppRes = rec.supportedResolutions(); - for (int i = 0; i < g_commonVideoResolutions.size(); ++i) { - CameraSettingsValue *r = g_commonVideoResolutions.at(i); - if (suppRes.contains(r->value().toSize())) - m_supportedVideoResolutions.append(r); - } - - - // Supported white balance modes - for (int i = 0; i < g_whiteBalanceModes.size(); ++i) { - CameraSettingsValue *m = g_whiteBalanceModes.at(i); - if (imageProc->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode(m->value().toInt()))) - m_supportedWhiteBalanceModes.append(m); - } - - // Supported scene modes - for (int i = 0; i < g_sceneModes.size(); ++i) { - CameraSettingsValue *sm = g_sceneModes.at(i); - if (exposure->isExposureModeSupported(QCameraExposure::ExposureMode(sm->value().toInt()))) - m_supportedSceneModes.append(sm); - } - - // Supported flash modes - for (int i = 0; i < g_flashModes.size(); ++i) { - CameraSettingsValue *sm = g_flashModes.at(i); - if (exposure->isFlashModeSupported(QCameraExposure::FlashModes(sm->value().toInt()))) - m_supportedFlashModes.append(sm); - } - - // Supported focus modes - for (int i = 0; i < g_focusModes.size(); ++i) { - CameraSettingsValue *sm = g_focusModes.at(i); - if (focus->isFocusModeSupported(QCameraFocus::FocusModes(sm->value().toInt()))) - m_supportedFocusModes.append(sm); - } - - delete imageCapture; - - emit supportedCaptureResolutionsChanged(); - emit supportedVideoResolutionsChanged(); - emit supportedWhiteBalanceModesChanged(); - emit supportedSceneModesChanged(); - emit supportedFlashModesChanged(); -} - - diff --git a/experimental/Camera/camerautils/camerautils.h b/experimental/Camera/camerautils/camerautils.h deleted file mode 100644 index 562b675..0000000 --- a/experimental/Camera/camerautils/camerautils.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef CAMERAUTILS_H -#define CAMERAUTILS_H - -#include <QObject> -#include <QVariant> - -class QCamera; - -class CameraSettingsValue : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) - -public: - CameraSettingsValue(const QString &n, const QVariant &v) - : QObject() - , m_name(n) - , m_value(v) - { } - - QString name() const { return m_name; } - void setName(const QString &n) { m_name = n; emit nameChanged(); } - - QVariant value() const { return m_value; } - void setValue(const QVariant &v) { m_value = v; emit valueChanged(); } - -Q_SIGNALS: - void nameChanged(); - void valueChanged(); - -private: - QString m_name; - QVariant m_value; -}; - -QDebug operator<<(QDebug, const CameraSettingsValue &); - -class CameraUtils : public QObject -{ - Q_OBJECT - Q_PROPERTY(QList<QObject*> supportedCaptureResolutions READ supportedCaptureResolutions NOTIFY supportedCaptureResolutionsChanged) - Q_PROPERTY(QList<QObject*> supportedWhiteBalanceModes READ supportedWhiteBalanceModes NOTIFY supportedWhiteBalanceModesChanged) - Q_PROPERTY(QList<QObject*> supportedSceneModes READ supportedSceneModes NOTIFY supportedSceneModesChanged) - Q_PROPERTY(QList<QObject*> supportedFlashModes READ supportedFlashModes NOTIFY supportedFlashModesChanged) - Q_PROPERTY(QList<QObject*> supportedFocusModes READ supportedFocusModes NOTIFY supportedFocusModesChanged) - Q_PROPERTY(QList<QObject*> supportedVideoResolutions READ supportedVideoResolutions NOTIFY supportedVideoResolutionsChanged) -public: - explicit CameraUtils(QObject *parent = 0); - ~CameraUtils(); - - Q_INVOKABLE void init(); - Q_INVOKABLE void setCamera(QObject *cam); - - QList<QObject*> supportedCaptureResolutions() const { return m_supportedResolutions; } - QList<QObject*> supportedVideoResolutions() const { return m_supportedVideoResolutions; } - QList<QObject*> supportedWhiteBalanceModes() const { return m_supportedWhiteBalanceModes; } - QList<QObject*> supportedSceneModes() const { return m_supportedSceneModes; } - QList<QObject*> supportedFlashModes() const { return m_supportedFlashModes; } - QList<QObject*> supportedFocusModes() const { return m_supportedFocusModes; } - -Q_SIGNALS: - void supportedCaptureResolutionsChanged(); - void supportedWhiteBalanceModesChanged(); - void supportedSceneModesChanged(); - void supportedFlashModesChanged(); - void supportedFocusModesChanged(); - void supportedVideoResolutionsChanged(); - - void done(); - -private Q_SLOTS: - void onCameraStatusChanged(); - void onError(); - -private: - QCamera *m_camera; - - QList<QObject*> m_supportedResolutions; - QList<QObject*> m_supportedVideoResolutions; - QList<QObject*> m_supportedWhiteBalanceModes; - QList<QObject*> m_supportedSceneModes; - QList<QObject*> m_supportedFlashModes; - QList<QObject*> m_supportedFocusModes; -}; - -#endif // CAMERAUTILS_H diff --git a/experimental/Camera/camerautils/camerautils.pro b/experimental/Camera/camerautils/camerautils.pro deleted file mode 100644 index 938a0a9..0000000 --- a/experimental/Camera/camerautils/camerautils.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -QT += qml multimedia - -TARGET = camerautilsplugin - -SOURCES += plugin.cpp \ - camerautils.cpp - -HEADERS += camerautils.h - -pluginfiles.files += \ - qmldir \ - -target.path += $$[QT_INSTALL_QML]/CameraUtils -pluginfiles.path += $$[QT_INSTALL_QML]/CameraUtils - -INSTALLS += target pluginfiles - diff --git a/experimental/Camera/camerautils/plugin.cpp b/experimental/Camera/camerautils/plugin.cpp deleted file mode 100644 index 2a8c3ea..0000000 --- a/experimental/Camera/camerautils/plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml/QQmlExtensionPlugin> -#include <QtQml/qqml.h> -#include <qdebug.h> - -#include "camerautils.h" - -class QExampleQmlPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri) - { - qmlRegisterType<CameraUtils>(uri, 1, 0, "CameraUtils"); - } -}; - - -#include "plugin.moc" diff --git a/experimental/Camera/camerautils/qmldir b/experimental/Camera/camerautils/qmldir deleted file mode 100644 index a5ab412..0000000 --- a/experimental/Camera/camerautils/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module CameraUtils -plugin camerautilsplugin |