android触屏对焦_Android相机对焦模式

在创建自定义相机应用时,允许用户选择自动对焦或触屏对焦模式。实现触屏对焦的方法包括调用`autoFocus()`并在`AutoFocusCallback`中处理对焦成功后执行拍照。在某些情况下,确保对焦成功后再拍照可以提高准确性,特别是在二维码扫描等场景下。
摘要由CSDN通过智能技术生成

I am trying to make a custom camera application

I want to let the users can choose the focus mode in this application.

The focus mode is auto and touch-to-focus

If we want to use touch-to-focus in the camera , how can be start with?

解决方案

Try this:

public void takePhoto(File photoFile, String workerName, int width, int height, int quality) {

if (getAutoFocusStatus()){

camera.autoFocus(new AutoFocusCallback() {

@Override

public void onAutoFocus(boolean success, Camera camera) {

camera.takePicture(shutterCallback, rawCallback, jpegCallback);

}

});

}else{

camera.takePicture(shutterCallback, rawCallback, jpegCallback);

}

However, I've also seen this to work, possibly more accurately:

if (getAutoFocusStatus()){

camera.autoFocus(new AutoFocusCallback() {

@Override

public void onAutoFocus(boolean success, Camera camera) {

if(success) camera.takePicture(shutterCallback, rawCallback, jpegCallback);

}

});

}else{

camera.takePicture(shutterCallback, rawCallback, jpegCallback);

}

The last one takes the picture at the moment the focussing is successfully completed. It works very well for using with QR scanning codes. I believe the same applies to cases like this.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值