Android相机对焦模式 [英] Android Camera Focus Mode
本文介绍了Android相机对焦模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试制作自定义相机应用程序 我想让用户可以在此应用程序中选择对焦模式.
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?
推荐答案
尝试一下:
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);
}
最后一个在成功完成聚焦时拍摄照片.与QR扫描代码一起使用时效果很好.我相信同样的情况也适用于这样的情况.
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.
这篇关于Android相机对焦模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文