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.
在创建自定义相机应用时,允许用户选择自动对焦或触屏对焦模式。实现触屏对焦的方法包括调用`autoFocus()`并在`AutoFocusCallback`中处理对焦成功后执行拍照。在某些情况下,确保对焦成功后再拍照可以提高准确性,特别是在二维码扫描等场景下。
3459

被折叠的 条评论
为什么被折叠?



