Add the spot for spot metering mode.
Not yet fully documented in QML - needs a bit of an overhaul first. Change-Id: Ic11684858fb872d0b4dcedf60b390571371db252 Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
c97f5f8c2e
commit
6b67a11032
@@ -104,6 +104,7 @@ class QDeclarativeCamera : public QObject, public QDeclarativeParserStatus
|
||||
|
||||
Q_ENUMS(FlashMode)
|
||||
Q_ENUMS(ExposureMode)
|
||||
Q_ENUMS(MeteringMode)
|
||||
|
||||
Q_ENUMS(FocusMode)
|
||||
Q_ENUMS(FocusPointMode)
|
||||
@@ -164,6 +165,12 @@ public:
|
||||
ExposureModeVendor = QCameraExposure::ExposureModeVendor
|
||||
};
|
||||
|
||||
enum MeteringMode {
|
||||
MeteringMatrix = QCameraExposure::MeteringMatrix,
|
||||
MeteringAverage = QCameraExposure::MeteringAverage,
|
||||
MeteringSpot = QCameraExposure::MeteringSpot
|
||||
};
|
||||
|
||||
enum FocusMode {
|
||||
FocusManual = QCameraFocus::ManualFocus,
|
||||
FocusHyperfocal = QCameraFocus::HyperfocalFocus,
|
||||
|
||||
@@ -253,7 +253,41 @@ void QDeclarativeCameraExposure::setExposureMode(QDeclarativeCamera::ExposureMod
|
||||
\fn void QDeclarativeCameraExposure::exposureModeChanged(QDeclarativeCamera::ExposureMode)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty QPointF CameraExposure::spotMeteringPoint
|
||||
\property QDeclarativeCameraExposure::spotMeteringPoint
|
||||
|
||||
The relative frame coordinates of the point to use for exposure metering (in relative
|
||||
frame coordinates). This point is only used in spot metering mode, and typically defaults
|
||||
to the center \c (0.5, 0.5).
|
||||
*/
|
||||
|
||||
QPointF QDeclarativeCameraExposure::spotMeteringPoint() const
|
||||
{
|
||||
return m_exposure->spotMeteringPoint();
|
||||
}
|
||||
|
||||
void QDeclarativeCameraExposure::setSpotMeteringPoint(const QPointF &point)
|
||||
{
|
||||
QPointF oldPoint(spotMeteringPoint());
|
||||
m_exposure->setSpotMeteringPoint(point);
|
||||
|
||||
if (oldPoint != spotMeteringPoint())
|
||||
emit spotMeteringPointChanged(spotMeteringPoint());
|
||||
}
|
||||
|
||||
QDeclarativeCamera::MeteringMode QDeclarativeCameraExposure::meteringMode() const
|
||||
{
|
||||
return QDeclarativeCamera::MeteringMode(m_exposure->meteringMode());
|
||||
}
|
||||
|
||||
void QDeclarativeCameraExposure::setMeteringMode(QDeclarativeCamera::MeteringMode mode)
|
||||
{
|
||||
QDeclarativeCamera::MeteringMode oldMode = meteringMode();
|
||||
m_exposure->setMeteringMode(QCameraExposure::MeteringMode(mode));
|
||||
if (oldMode != meteringMode())
|
||||
emit meteringModeChanged(meteringMode());
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ class QDeclarativeCameraExposure : public QObject
|
||||
|
||||
Q_PROPERTY(QDeclarativeCamera::ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
|
||||
|
||||
Q_PROPERTY(QPointF spotMeteringPoint READ spotMeteringPoint WRITE setSpotMeteringPoint NOTIFY spotMeteringPointChanged)
|
||||
Q_PROPERTY(QDeclarativeCamera::MeteringMode meteringMode READ meteringMode WRITE setMeteringMode NOTIFY meteringModeChanged)
|
||||
|
||||
public:
|
||||
~QDeclarativeCameraExposure();
|
||||
|
||||
@@ -92,6 +95,12 @@ public:
|
||||
qreal manualShutterSpeed() const;
|
||||
qreal manualAperture() const;
|
||||
|
||||
QPointF spotMeteringPoint() const;
|
||||
void setSpotMeteringPoint(const QPointF &point);
|
||||
|
||||
QDeclarativeCamera::MeteringMode meteringMode() const;
|
||||
void setMeteringMode(QDeclarativeCamera::MeteringMode mode);
|
||||
|
||||
public Q_SLOTS:
|
||||
void setExposureMode(QDeclarativeCamera::ExposureMode);
|
||||
void setExposureCompensation(qreal ev);
|
||||
@@ -116,6 +125,9 @@ Q_SIGNALS:
|
||||
void exposureCompensationChanged(qreal);
|
||||
void exposureModeChanged(QDeclarativeCamera::ExposureMode);
|
||||
|
||||
void meteringModeChanged(QDeclarativeCamera::MeteringMode);
|
||||
void spotMeteringPointChanged(QPointF);
|
||||
|
||||
private:
|
||||
friend class QDeclarativeCamera;
|
||||
QDeclarativeCameraExposure(QCamera *camera, QObject *parent = 0);
|
||||
|
||||
@@ -311,6 +311,33 @@ void QCameraExposure::setMeteringMode(QCameraExposure::MeteringMode mode)
|
||||
d_func()->exposureControl->setMeteringMode(mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QCameraExposure::spotMeteringPoint
|
||||
|
||||
When supported, this property is the (normalized) position of the point of the image
|
||||
where exposure metering will be performed. This is typically used to indicate an
|
||||
"interesting" area of the image that should be exposed properly.
|
||||
|
||||
The coordinates are relative frame coordinates:
|
||||
QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center,
|
||||
which is typically the default spot metering point.
|
||||
|
||||
The spot metering point is only used with spot metering mode.
|
||||
\since 1.1
|
||||
*/
|
||||
|
||||
QPointF QCameraExposure::spotMeteringPoint() const
|
||||
{
|
||||
return d_func()->exposureControl ? d_func()->exposureControl->exposureParameter(QCameraExposureControl::SpotMeteringPoint).toPointF() : QPointF();
|
||||
}
|
||||
|
||||
void QCameraExposure::setSpotMeteringPoint(const QPointF &point)
|
||||
{
|
||||
if (d_func()->exposureControl)
|
||||
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::SpotMeteringPoint, point);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns true if the metering \a mode is supported.
|
||||
\since 1.1
|
||||
|
||||
@@ -120,6 +120,9 @@ public:
|
||||
|
||||
bool isMeteringModeSupported(MeteringMode mode) const;
|
||||
|
||||
QPointF spotMeteringPoint() const;
|
||||
void setSpotMeteringPoint(const QPointF &point);
|
||||
|
||||
int isoSensitivity() const;
|
||||
QList<int> supportedIsoSensitivities(bool *continuous = 0) const;
|
||||
|
||||
|
||||
@@ -133,7 +133,6 @@ QCameraExposureControl::~QCameraExposureControl()
|
||||
\since 1.1
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn bool QCameraExposureControl::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
|
||||
Returns true if the metering \a mode is supported.
|
||||
@@ -162,6 +161,9 @@ QCameraExposureControl::~QCameraExposureControl()
|
||||
This value is only used in the \l{QCameraExposure::FlashManual}{manual flash mode}.
|
||||
\value FlashCompensation
|
||||
Flash compensation, specified as qreal EV value.
|
||||
\value SpotMeteringPoint
|
||||
The relative frame coordinate of the point to use for exposure metering
|
||||
in spot metering mode, specified as a QPointF.
|
||||
\value ExtendedExposureParameter
|
||||
The base value for platform specific extended parameters.
|
||||
For such parameters the sequential values starting from ExtendedExposureParameter shuld be used.
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
ExposureCompensation = 4,
|
||||
FlashPower = 5,
|
||||
FlashCompensation = 6,
|
||||
SpotMeteringPoint = 7,
|
||||
ExtendedExposureParameter = 1000
|
||||
};
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ SimulatorCameraExposureControl::SimulatorCameraExposureControl(SimulatorCameraSe
|
||||
QCameraExposureControl(parent),
|
||||
mExposureMode(QCameraExposure::ExposureAuto),
|
||||
mMeteringMode(QCameraExposure::MeteringAverage),
|
||||
mSpot(0.5, 0.5),
|
||||
mSession(session),
|
||||
mSettings(0)
|
||||
{
|
||||
@@ -138,6 +139,7 @@ bool SimulatorCameraExposureControl::isParameterSupported(ExposureParameter para
|
||||
case QCameraExposureControl::Aperture:
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
case QCameraExposureControl::SpotMeteringPoint:
|
||||
return true;
|
||||
case QCameraExposureControl::FlashPower:
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
@@ -161,6 +163,10 @@ QVariant SimulatorCameraExposureControl::exposureParameter(ExposureParameter par
|
||||
return QVariant(shutterSpeed());
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
return QVariant(exposureCompensation());
|
||||
|
||||
case QCameraExposureControl::SpotMeteringPoint:
|
||||
return mSpot;
|
||||
|
||||
case QCameraExposureControl::FlashPower:
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
// Not supported
|
||||
@@ -303,6 +309,16 @@ bool SimulatorCameraExposureControl::setExposureParameter(ExposureParameter para
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
return false;
|
||||
|
||||
case QCameraExposureControl::SpotMeteringPoint:
|
||||
{
|
||||
static QRectF valid(0, 0, 1, 1);
|
||||
if (valid.contains(value.toPointF())) {
|
||||
mSpot = value.toPointF();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default:
|
||||
// Not supported
|
||||
return false;
|
||||
@@ -324,7 +340,8 @@ QString SimulatorCameraExposureControl::extendedParameterName(ExposureParameter
|
||||
return QString("Flash Power");
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
return QString("Flash Compensation");
|
||||
|
||||
case QCameraExposureControl::SpotMeteringPoint:
|
||||
return QString("Spot Metering Point");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ private: // Internal - Implementing ExposureParameter
|
||||
private: // Data
|
||||
QCameraExposure::ExposureMode mExposureMode;
|
||||
QCameraExposure::MeteringMode mMeteringMode;
|
||||
QPointF mSpot;
|
||||
SimulatorCameraSession *mSession;
|
||||
SimulatorCameraSettings *mSettings;
|
||||
};
|
||||
|
||||
@@ -235,6 +235,10 @@ void tst_QCamera::testSimpleCameraExposure()
|
||||
cameraExposure->setMeteringMode(QCameraExposure::MeteringSpot);
|
||||
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
|
||||
|
||||
QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF());
|
||||
cameraExposure->setSpotMeteringPoint(QPointF(0.5f, 0.5f));
|
||||
QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF());
|
||||
|
||||
QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
|
||||
cameraExposure->setExposureCompensation(2.0);
|
||||
QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
|
||||
@@ -626,6 +630,15 @@ void tst_QCamera::testCameraExposure()
|
||||
cameraExposure->setMeteringMode(QCameraExposure::MeteringSpot);
|
||||
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringSpot);
|
||||
|
||||
cameraExposure->setSpotMeteringPoint(QPointF(0.5f, 0.25f));
|
||||
QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0.5f, 0.25f));
|
||||
cameraExposure->setSpotMeteringPoint(QPointF(0.25f, 56.3f));
|
||||
QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0.5f, 0.25f));
|
||||
cameraExposure->setSpotMeteringPoint(QPointF(0, 0));
|
||||
QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(0, 0));
|
||||
cameraExposure->setSpotMeteringPoint(QPointF(1, 1));
|
||||
QCOMPARE(cameraExposure->spotMeteringPoint(), QPointF(1, 1));
|
||||
|
||||
QCOMPARE(cameraExposure->exposureCompensation(), 0.0);
|
||||
cameraExposure->setExposureCompensation(2.0);
|
||||
QCOMPARE(cameraExposure->exposureCompensation(), 2.0);
|
||||
|
||||
@@ -56,7 +56,8 @@ public:
|
||||
m_meteringMode(QCameraExposure::MeteringMatrix),
|
||||
m_exposureCompensation(0),
|
||||
m_exposureMode(QCameraExposure::ExposureAuto),
|
||||
m_flashMode(QCameraExposure::FlashAuto)
|
||||
m_flashMode(QCameraExposure::FlashAuto),
|
||||
m_spot(0.5, 0.5)
|
||||
{
|
||||
m_isoRanges << 100 << 200 << 400 << 800;
|
||||
m_apertureRanges << 2.8 << 4.0 << 5.6 << 8.0 << 11.0 << 16.0;
|
||||
@@ -106,6 +107,7 @@ public:
|
||||
case QCameraExposureControl::ISO:
|
||||
case QCameraExposureControl::Aperture:
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
case QCameraExposureControl::SpotMeteringPoint:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -123,6 +125,8 @@ public:
|
||||
return QVariant(m_aperture);
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
return QVariant(m_shutterSpeed);
|
||||
case QCameraExposureControl::SpotMeteringPoint:
|
||||
return QVariant(m_spot);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -234,6 +238,17 @@ public:
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case QCameraExposureControl::SpotMeteringPoint:
|
||||
{
|
||||
static QRectF valid(0, 0, 1, 1);
|
||||
if (valid.contains(value.toPointF())) {
|
||||
m_spot = value.toPointF();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -264,7 +279,6 @@ public:
|
||||
{
|
||||
return mode == QCameraExposure::MeteringAverage
|
||||
|| mode == QCameraExposure::MeteringMatrix
|
||||
|| mode == QCameraExposure::MeteringAverage
|
||||
|| mode == QCameraExposure::MeteringSpot;
|
||||
}
|
||||
|
||||
@@ -277,6 +291,7 @@ private:
|
||||
QCameraExposure::ExposureMode m_exposureMode;
|
||||
QCameraExposure::FlashModes m_flashMode;
|
||||
QVariantList m_isoRanges,m_apertureRanges, m_shutterRanges, m_exposureRanges, m_res;
|
||||
QPointF m_spot;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERAEXPOSURECONTROL_H
|
||||
|
||||
Reference in New Issue
Block a user