CopperSpice API  1.9.2
QCameraFocus Class Reference

An interface for focus and zoom related camera settings. More...

Inheritance diagram for QCameraFocus:
QObject

Public Typedefs

using FocusModes = QFlags< FocusMode >
 

Public Types

enum  FocusMode
 
enum  FocusPointMode
 

Public Signals

void digitalZoomChanged (double value)
 
void focusZonesChanged ()
 
void maximumDigitalZoomChanged (double value)
 
void maximumOpticalZoomChanged (double value)
 
void opticalZoomChanged (double value)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

QPointF customFocusPoint () const
 
double digitalZoom () const
 
FocusModes focusMode () const
 
QCameraFocus::FocusPointMode focusPointMode () const
 
QCameraFocusZoneList focusZones () const
 
bool isAvailable () const
 
bool isFocusModeSupported (FocusModes mode) const
 
bool isFocusPointModeSupported (QCameraFocus::FocusPointMode mode) const
 
double maximumDigitalZoom () const
 
double maximumOpticalZoom () const
 
double opticalZoom () const
 
void setCustomFocusPoint (const QPointF &point)
 
void setFocusMode (FocusModes mode)
 
void setFocusPointMode (QCameraFocus::FocusPointMode mode)
 
void zoomTo (double opticalZoom, double digitalZoom)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Properties

 customFocusPoint
 
 digitalZoom
 
 focusMode
 
 focusPointMode
 
 focusZones
 
 opticalZoom
 
- Properties inherited from QObject
 objectName
 

Friends

class QCamera
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

The QCameraFocus class provides an interface for focus and zoom related camera settings.

On hardware that supports it this class lets you adjust the focus or zoom (both optical and digital). This also includes things like "Macro" mode for close up work (e.g. reading barcodes, or recognizing letters), or "touch to focus" indicating an interesting area of the viewfinder for the hardware to attempt to focus on.

QCameraFocus *focus = camera->focus();
focus->setFocusPointMode(QCameraFocus::FocusPointCustom);
// a point near the bottom left, 25% away from the corner, near that shiny vase
focus->setCustomFocusPoint(QPointF(0.25f, 0.75f));

Zooming can be accomplished in a number of ways - usually the more expensive but higher quality approach is an optical zoom, which allows using the full extent of the camera sensor to gather image pixels. In addition it is possible to digitally zoom, which will generally just enlarge part of the sensor frame and throw away other parts. If the camera hardware supports optical zoom this should generally always be used first. The maximumOpticalZoom() method allows this to be checked. The zoomTo() method allows changing both optical and digital zoom at once.

focus->zoomTo(3.0, 4.0); // super zoom

Some notes on autofocus

Some hardware supports a movable focus lens assembly, and typically this hardware also supports automatically focusing via some heuristic. You can influence this via the FocusPointMode setting - typically the center of the frame is brought into focus, but some hardware also supports focusing on any faces detected in the frame, or on a specific point (usually provided by a user in a "touch to focus" scenario).

This class (in combination with QCameraFocusZone) can expose information on what parts of the camera sensor image are in focus or are being used for autofocusing via the focusZones() property.

focus->setFocusPointMode(QCameraFocus::FocusPointAuto);
for (QCameraFocusZone zone : zones) {
if (zone.status() == QCameraFocusZone::Focused) {
// Draw a green box at zone.area()
} else if (zone.status() == QCameraFocusZone::Selected) {
// This area is selected for autofocusing, but is not in focus
// Draw a yellow box at zone.area()
}
}
See also
QCameraFocusZone

Member Typedef Documentation

Typedef for QFlags<FocusMode> which contains an OR combination of FocusMode values.

Refer to QCameraFocus::FocusMode for the enum documentation.

Member Enumeration Documentation

Indicates how the camera will focus.

Constant Value Description
QCameraFocus::ManualFocus 0x1 Manual or fixed focus mode.
QCameraFocus::HyperfocalFocus 0x02 Focus to hyperfocal distance, with the maximum depth of field achieved. All objects at distances from half of this distance out to infinity will be acceptably sharp.
QCameraFocus::InfinityFocus 0x04 Focus strictly to infinity.
QCameraFocus::AutoFocus 0x8 One-shot auto focus mode.
QCameraFocus::ContinuousFocus 0x10 Continuous auto focus mode.
QCameraFocus::MacroFocus 0x20 One shot auto focus to objects close to camera.

Indicates how the camera selects a focus point.

Constant Value Description
QCameraFocus::FocusPointAuto 0 Automatically select one or multiple focus points.
QCameraFocus::FocusPointCenter 1 Focus to the frame center.
QCameraFocus::FocusPointFaceDetection 2 Focus on faces in the frame.
QCameraFocus::FocusPointCustom 3 Focus to the custom point, defined by QCameraFocus::customFocusPoint property.

Method Documentation

QPointF QCameraFocus::customFocusPoint ( ) const

Returns the value of the property.

double QCameraFocus::digitalZoom ( ) const

Returns the value of the property.

void QCameraFocus::digitalZoomChanged ( double  value)
signal

Signal emitted when digital zoom value changes to new value.

FocusModes QCameraFocus::focusMode ( ) const

Returns the value of the property.

FocusPointMode QCameraFocus::focusPointMode ( ) const

Returns the value of the property.

QCameraFocusZoneList QCameraFocus::focusZones ( ) const

Returns the value of the property.

void QCameraFocus::focusZonesChanged ( )
signal

This signal is emitted when the set of zones used in autofocusing is changed. This can change when a zone is focused or loses focus, or new focus zones have been detected.

bool QCameraFocus::isAvailable ( ) const

Returns true if focus related settings are supported by this camera.

You may need to also check if any specific features are supported.

bool QCameraFocus::isFocusModeSupported ( FocusModes  mode) const

Returns true if the focus mode is supported by camera.

bool QCameraFocus::isFocusPointModeSupported ( QCameraFocus::FocusPointMode  mode) const

Returns true if focus point mode is supported.

double QCameraFocus::maximumDigitalZoom ( ) const

Returns the maximum digital zoom. This will be 1.0 on cameras that do not support digital zoom.

void QCameraFocus::maximumDigitalZoomChanged ( double  value)
signal

Signal is emitted when the maximum supported digital value changes. The maximum supported zoom value can depend on other camera settings, like capture mode or resolution.

double QCameraFocus::maximumOpticalZoom ( ) const

Returns the maximum optical zoom. This will be 1.0 on cameras that do not support optical zoom.

void QCameraFocus::maximumOpticalZoomChanged ( double  value)
signal

Signal is emitted when the maximum supported optical value changes.

double QCameraFocus::opticalZoom ( ) const

Returns the value of the property.

void QCameraFocus::opticalZoomChanged ( double  value)
signal

Signal emitted when optical zoom value changes to new value.

void QCameraFocus::setCustomFocusPoint ( const QPointF point)

Sets the value of the property to point.

void QCameraFocus::setFocusMode ( FocusModes  mode)

Sets the value of the property to mode.

void QCameraFocus::setFocusPointMode ( QCameraFocus::FocusPointMode  mode)

Sets the value of the property to mode.

void QCameraFocus::zoomTo ( double  opticalZoom,
double  digitalZoom 
)

Set the camera opticalZoom and digitalZoom values. Since there may be a physical component to move, the change in zoom value may not be instantaneous.

Property Documentation

QCameraFocus::customFocusPoint

This property represents the position of the custom focus point, in relative frame coordinates: QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center.

The custom focus point property is used only in FocusPointCustom focus mode.

PropertiesClass Methods
read customFocusPoint
write setCustomFocusPoint
QCameraFocus::digitalZoom

This property holds the current digital zoom value.

PropertiesClass Methods
read digitalZoom
notify digitalZoomChanged
QCameraFocus::focusMode

This property holds the current camera focus mode. This controls the way the camera lens assembly is configured.

PropertiesClass Methods
read focusMode
write setFocusMode
QCameraFocus::focusPointMode

This property holds the current camera focus point selection mode. If the camera focus mode is set to use an autofocusing mode, this property controls the way the camera will select areas of the frame to use for autofocusing.

PropertiesClass Methods
read focusPointMode
write setFocusPointMode
QCameraFocus::focusZones

Returns the list of active focus zones.

If QCamera::FocusPointAuto or QCamera::FocusPointFaceDetection focus mode is selected this method returns the list of zones the camera is actually focused on. The coordinates system is the same as for custom focus points: QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center.

PropertiesClass Methods
read focusZones
notify focusZonesChanged
QCameraFocus::opticalZoom

This property holds the current optical zoom value.

PropertiesClass Methods
read opticalZoom
notify opticalZoomChanged