我开发了一个 android 应用程序来通过 camerax 扫描 QR 码。预览时如何禁用自动对焦?
没试过
public void initCamera(Fragment fragment, OnQRResultListener onQRResultListener) {
mOnQRResultListener = onQRResultListener;
PreviewConfig previewBuild = new PreviewConfig.Builder()
.setTargetResolution(new Size(getWidth(), getHeight()))
.setTargetAspectRatio(new Rational(1, 1))
.setLensFacing(CameraX.LensFacing.FRONT)
.build();
preview = new Preview(previewBuild);
preview.setOnPreviewOutputUpdateListener(new Preview.OnPreviewOutputUpdateListener() {
@Override
public void onUpdated(Preview.PreviewOutput output) {
textureView.setSurfaceTexture(output.getSurfaceTexture());
}
});
HandlerThread analyzerThread = new HandlerThread("BarcodeAnalyzer");
analyzerThread.start();
ImageAnalysisConfig analysisBuild = new ImageAnalysisConfig.Builder()
.setTargetResolution(new Size(getWidth(), getHeight()))
.setTargetAspectRatio(new Rational(1, 1))
.setLensFacing(CameraX.LensFacing.FRONT)
.setImageReaderMode(ImageAnalysis.ImageReaderMode.ACQUIRE_LATEST_IMAGE)
.setCallbackHandler(new Handler(analyzerThread.getLooper()))
.build();
ImageAnalysis analysis = new ImageAnalysis(analysisBuild);
analysis.setAnalyzer(new QRCodeAnalyzer(onAnalyzerResultListener));
CameraX.bindToLifecycle(fragment, preview, analysis);
}
它会慢慢扫描 qr 结果