如何在Android上关注QML Camera
?我已经尝试了所有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();
}
}
}
}
答案 0 :(得分:1)
如果您使用的是Qt 5.4或更低版本,则不能。 QCamera
中存在一个错误,可防止触发自动对焦。查看错误及其解决方法here。
自Qt 5.5起,解决方案已合并,错误已解决。