QML相机焦点不起作用

And*_*eas 5 qt android qml android-camera qtquick2

如何Camera在Android上关注QML ?我已经尝试了所有focusMode但没有任何作用.相机应用正确关注我的设备.

这是我的QML文件:

import QtQuick 2.3
import QtMultimedia 5.2

Item {
    property int scanerButtonWidth: 80
    property int scanerButtonHeight: 60

    Rectangle {
        width: parent.width
        height: scanerButtonHeight + 10
        color: Qt.rgba(0,0,0,1)
    }

    VideoOutput {
        width: parent.width
        height: parent.height
        source: camera
        anchors.fill: parent
        autoOrientation: true
    }

    Camera {
        id: camera
        imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
        captureMode: Camera.CaptureStillImage
        exposure {
            exposureMode: Camera.ExposureAuto
        }

        focus {
            focusMode: Camera.FocusContinuous
            focusPointMode: Camera.FocusPointCenter
        }

        imageCapture {
            onImageCaptured: {
                otpGeneratorApp.scanedQR_Code( preview, false, type )
                qrCodeScanner.visible = false
            }
        }
    }


    Rectangle {
        width: parent.width
        height: scanerButtonHeight + 10
        y: parent.height - ( height )
        color: Qt.rgba(0,0,0,1)

        Button {
            id: captureButton;
            width: scanerButtonWidth;
            height: scanerButtonHeight;
            x: parent.width * 0.5 - ( width / 2);
            y: parent.height - ( height + 5);
            text: qsTr( "[O]" );
            onClicked: {
                 camera.imageCapture.capture();
            }
        }

        Button {
            id: focus
            width: scanerButtonWidth;
            height: scanerButtonHeight;
            text: qsTr("Focus");
            x: captureButton.x + ( captureButton.width + 10 );
            y: parent.height - ( height + 5);
            onClicked: {
                 camera.searchAndLock();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Fab*_*ien 1

如果您使用的是 Qt 5.4 或更低版本,则不能。有一个错误会QCamera阻止自动对焦被触发。请参阅此处的错误和解决方法。

从 Qt 5.5 开始,已经合并了一个解决方案并解决了该错误。