我开发了一个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结果
答案 0 :(得分:0)
查看此链接:
也可以在 stackoverflow 上看到这个答案:
https://stackoverflow.com/a/60095886/8401205
这是一个简单的java版本的小代码段:
FocusMeteringAction action = new FocusMeteringAction.Builder(point, FocusMeteringAction.FLAG_AF).disableAutoCancel().build();