Qt World Summit: Register Today!

QCamera's FocusPointMode not works on Android

  • Hi,
    after searching here and in internet and trying different ways I can still not use the FocusPointMode of QCameraFocus for a LG G2 and Honor6, despite other camera apps works correctly.

    My requirement is to show a user of my camera app when the image in VideoOutput is focused, e.g during focusing the color of the cross is red, and if focused it's changing to green.

    Qt docu:
    "You can use this information to present visual feedback - for example, drawing rectangles around areas of the camera frame that are in focus, or changing the color of a zone as it comes into focus."

    QList<QCameraFocusZone> zones = focus->focusZones();
    foreach (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()

    Related signal from Qt docu:

    void QCameraFocus::focusZonesChanged()

    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.

    My Code:

    m_pCamFocus = m_pCamera->focus();
    bool isav = m_pCamFocus->isAvailable(); \\ true
    bool fm1 = m_pCamFocus->isFocusModeSupported(QCameraFocus::ManualFocus); \\ false
    bool fm2 = m_pCamFocus->isFocusModeSupported(QCameraFocus::HyperfocalFocus); \\ false
    bool fm3 = m_pCamFocus->isFocusModeSupported(QCameraFocus::InfinityFocus); \\ true
    bool fm4 = m_pCamFocus->isFocusModeSupported(QCameraFocus::AutoFocus); \\ true
    bool fm5 = m_pCamFocus->isFocusModeSupported(QCameraFocus::ContinuousFocus); \\ true
    bool fm6 = m_pCamFocus->isFocusModeSupported(QCameraFocus::MacroFocus); \\ true
    QCameraFocus::FocusPointMode fpm = m_pCamFocus->focusPointMode();
    bool fpm1 = m_pCamFocus->isFocusPointModeSupported(QCameraFocus::FocusPointAuto); \\ true
    bool fpm2 = m_pCamFocus->isFocusPointModeSupported(QCameraFocus::FocusPointCenter); \\ true
    bool fpm3 = m_pCamFocus->isFocusPointModeSupported(QCameraFocus::FocusPointFaceDetection); \\ false
    bool fpm4 = m_pCamFocus->isFocusPointModeSupported(QCameraFocus::FocusPointCustom); \\ true
    void Qml::updFocus() {
        QList<QCameraFocusZone> fpl = m_pCamFocus->focusZones();
        foreach (QCameraFocusZone var, fpl) {
             qDebug() << "fpl" << var.status(); \\ 2
             qDebug() << "area" << var.area(); \\ QRectF(0.486979,0.482639 0.0260417x0.0347222)

    Independently which FocusPointMode I select the result is always the same. The signal focusZonesChanged() is fired once and status=2 and area=QRectF(center of Videooutput).

    I tried also with services

    service = m_pCamera->service();
    if (service) {
           focusControl = qobject_cast<QCameraFocusControl *>(service->requestControl(QCameraFocusControl_iid));

    Conspicuous in the Appilcation output window of Qt Creator I see the message

    D/CameraClient(  338): cancelAutoFocus (pid 18372)

    So my guess is that the signal focusZonesChanged() is fired only once because the AutoFocus is cancelled. But why and on both different smartphones? Other apps works correctly.

    Did I missunderstand something?

    Thanks in advance for your help...

Log in to reply