CameraFocus QML Type | Qt Multimedia 5.15.18

- Qt 5.15
- Qt Multimedia
- QML Types
- CameraFocus QML Type
- Qt 5.15.18 Reference Documentation

# CameraFocus QML Type

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

Import Statement: | import QtMultimedia 5.15

- List of all members, including inherited members
- Obsolete members

## Properties

- customFocusPoint : point
- focusMode : enumeration
- focusPointMode : enumeration
- focusZones : list<focusZone>
- supportedFocusModes : list<FocusMode>
- supportedFocusPointModes : list<enumeration>

## Detailed Description

This type allows control over manual and automatic focus settings, including information about any parts of the camera frame that are selected for autofocusing.

It should not be constructed separately, instead the `focus` property of a Camera should be used.

     Item {
         width: 640
         height: 360

         Camera {
             id: camera

             focus {
                 focusMode: Camera.FocusMacro
                 focusPointMode: Camera.FocusPointCustom
                 customFocusPoint: Qt.point(0.2, 0.2) // Focus relative to top-left corner
             }
         }

         VideoOutput {
             source: camera
             anchors.fill: parent
         }
     }

## Property Documentation

customFocusPoint : point

This property holds the position of 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.

Custom focus point is used only in FocusPointCustom focus mode.

focusMode : enumeration

This property holds the current camera focus mode, which can be one of the following values:

Value | Description
--- | ---
FocusManual | Manual or fixed focus mode.
FocusHyperfocal | 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.
FocusInfinity | Focus strictly to infinity.
FocusAuto | One-shot auto focus mode.
FocusContinuous | Continuous auto focus mode.
FocusMacro | One shot auto focus to objects close to camera.

It's possible to combine multiple Camera::FocusMode values, for example Camera.FocusMacro + Camera.FocusContinuous.

In automatic focusing modes, the focusPointMode property and focusZones property provide information and control over how automatic focusing is performed.

focusPointMode : enumeration

This property holds the current camera focus point mode. It is used in automatic focusing modes to determine what to focus on. If the current focus point mode is `Camera.FocusPointCustom`, the customFocusPoint property allows you to specify which part of the frame to focus on.

The property can take one of the following values:

Value | Description
--- | ---
FocusPointAuto | Automatically select one or multiple focus points.
FocusPointCenter | Focus to the frame center.
FocusPointFaceDetection | Focus on faces in the frame.
FocusPointCustom | Focus to the custom point, defined by the customFocusPoint property.

focusZones : list<focusZone>

This property holds the list of current camera focus zones, each including `area` specified in the same coordinates as customFocusPoint, and zone `status` as one of the following values:

Value | Description
--- | ---
Camera.FocusAreaUnused | This focus point area is currently unused in autofocusing.
Camera.FocusAreaSelected | This focus point area is used in autofocusing, but is not in focus.
Camera.FocusAreaFocused | This focus point is used in autofocusing, and is in focus.

     VideoOutput {
         id: viewfinder
         source: camera

         //display focus areas on camera viewfinder:
         Repeater {
               model: camera.focus.focusZones

               Rectangle {
                   border {
                       width: 2
                       color: status == Camera.FocusAreaFocused ? "green" : "white"
                   }
                   color: "transparent"

                   // Map from the relative, normalized frame coordinates
                   property variant mappedRect: viewfinder.mapNormalizedRectToItem(area);

                   x: mappedRect.x
                   y: mappedRect.y
                   width: mappedRect.width
                   height: mappedRect.height
               }
         }
     }

supportedFocusModes : list<FocusMode>

This property holds the supported focus modes of the camera.

This property was introduced in Qt 5.11.

See also focusMode.

supportedFocusPointModes : list<enumeration>

This property holds the supported focus point modes of the camera.

This property was introduced in Qt 5.10.

See also focusPointMode.