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

Synopsis¶
Functions¶
def
customFocusPoint
()def
digitalZoom
()def
focusMode
()def
focusPointMode
()def
focusZones
()def
isAvailable
()def
isFocusModeSupported
(mode)def
isFocusPointModeSupported
(arg__1)def
maximumDigitalZoom
()def
maximumOpticalZoom
()def
opticalZoom
()def
setCustomFocusPoint
(point)def
setFocusMode
(mode)def
setFocusPointMode
(mode)def
zoomTo
(opticalZoom, digitalZoom)
Signals¶
def
digitalZoomChanged
(arg__1)def
focusZonesChanged
()def
maximumDigitalZoomChanged
(arg__1)def
maximumOpticalZoomChanged
(arg__1)def
opticalZoomChanged
(arg__1)
Detailed Description¶
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 recognising 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); focus->setCustomFocusPoint(QPointF(0.25f, 0.75f)); // A point near the bottom left, 25% away from the corner, near that shiny vaseZooming 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. ThezoomTo()
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 thefocusZones()
property:focus->setFocusPointMode(QCameraFocus::FocusPointAuto); const QList<QCameraFocusZone> zones = focus->focusZones(); for (const 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
-
PySide2.QtMultimedia.QCameraFocus.
FocusMode
¶ Constant
Description
QCameraFocus.ManualFocus
Manual or fixed focus mode.
QCameraFocus.HyperfocalFocus
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
Focus strictly to infinity.
QCameraFocus.AutoFocus
One-shot auto focus mode.
QCameraFocus.ContinuousFocus
Continuous auto focus mode.
QCameraFocus.MacroFocus
One shot auto focus to objects close to camera.
-
PySide2.QtMultimedia.QCameraFocus.
FocusPointMode
¶ Constant
Description
QCameraFocus.FocusPointAuto
Automatically select one or multiple focus points.
QCameraFocus.FocusPointCenter
Focus to the frame center.
QCameraFocus.FocusPointFaceDetection
Focus on faces in the frame.
QCameraFocus.FocusPointCustom
Focus to the custom point, defined by
customFocusPoint
property.
-
PySide2.QtMultimedia.QCameraFocus.
customFocusPoint
()¶ - Return type
QPointF
See also
-
PySide2.QtMultimedia.QCameraFocus.
digitalZoom
()¶ - Return type
qreal
-
PySide2.QtMultimedia.QCameraFocus.
digitalZoomChanged
(arg__1)¶ - Parameters
arg__1 –
qreal
-
PySide2.QtMultimedia.QCameraFocus.
focusMode
()¶ - Return type
FocusModes
See also
-
PySide2.QtMultimedia.QCameraFocus.
focusPointMode
()¶ - Return type
See also
-
PySide2.QtMultimedia.QCameraFocus.
focusZones
()¶ - Return type
-
PySide2.QtMultimedia.QCameraFocus.
focusZonesChanged
()¶
-
PySide2.QtMultimedia.QCameraFocus.
isAvailable
()¶ - Return type
bool
Returns true if focus related settings are supported by this camera.
You may need to also check if any specific features are supported.
-
PySide2.QtMultimedia.QCameraFocus.
isFocusModeSupported
(mode)¶ - Parameters
mode –
FocusModes
- Return type
bool
Returns true if the focus
mode
is supported by camera.
-
PySide2.QtMultimedia.QCameraFocus.
isFocusPointModeSupported
(arg__1)¶ - Parameters
arg__1 –
FocusPointMode
- Return type
bool
Returns true if focus point
mode
is supported.
-
PySide2.QtMultimedia.QCameraFocus.
maximumDigitalZoom
()¶ - Return type
qreal
Returns the maximum digital zoom
This will be
1.0
on cameras that do not support digital zoom.
-
PySide2.QtMultimedia.QCameraFocus.
maximumDigitalZoomChanged
(arg__1)¶ - Parameters
arg__1 –
qreal
-
PySide2.QtMultimedia.QCameraFocus.
maximumOpticalZoom
()¶ - Return type
qreal
Returns the maximum optical zoom.
This will be
1.0
on cameras that do not support optical zoom.
-
PySide2.QtMultimedia.QCameraFocus.
maximumOpticalZoomChanged
(arg__1)¶ - Parameters
arg__1 –
qreal
-
PySide2.QtMultimedia.QCameraFocus.
opticalZoom
()¶ - Return type
qreal
-
PySide2.QtMultimedia.QCameraFocus.
opticalZoomChanged
(arg__1)¶ - Parameters
arg__1 –
qreal
-
PySide2.QtMultimedia.QCameraFocus.
setCustomFocusPoint
(point)¶ - Parameters
point –
QPointF
See also
-
PySide2.QtMultimedia.QCameraFocus.
setFocusMode
(mode)¶ - Parameters
mode –
FocusModes
See also
-
PySide2.QtMultimedia.QCameraFocus.
setFocusPointMode
(mode)¶ - Parameters
mode –
FocusPointMode
See also
-
PySide2.QtMultimedia.QCameraFocus.
zoomTo
(opticalZoom, digitalZoom)¶ - Parameters
opticalZoom –
qreal
digitalZoom –
qreal
Set the camera
optical
anddigital
zoom values.Since there may be a physical component to move, the change in zoom value may not be instantaneous.
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.