手动对焦在camera2

手动对焦在camera2

本文介绍了手动对焦在camera2,android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找手机焦点的例子在camera2在Android。
我试图获得最小焦距和可用焦距如下所示,但它没有帮助。如何控制焦距?

i am looking for an example of manual focus in camera2 in android.I tried to get minimum focus distance and available focal lengths shown below, but it didn't help. How to control the focus distance ?

float minimumLens = characteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);

float[] lensDistances = characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS); 

我需要用seekbar控制它。
提前感谢。

I need to control it with seekbar.Thanks in advance.

推荐答案

 switch (seekBar.getId()) {
            case R.id.sb_focus:
                float minimumLens = mCameraCharacteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);
                float num = (((float) i) * minimumLens / 100);
                mPreviewBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, num);
                int showNum = (int) num;
                mSeekBarTextView.setText("focus:" + showNum);
                break;}

注意,CONTROL_AF_MODE应该为OFF。




行1109中的代码

be careful ,CONTROL_AF_MODE should be OFF.
https://github.com/pinguo-yuyidong/Camera2/blob/master/app/src/main/java/us/yydcdut/androidltest/ui/DisplayFragment.java
code in Line 1109

这篇关于手动对焦在camera2,android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 17:37