本文介绍了在camera2,android中手动对焦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找android中camera2手动对焦的示例.我试图获得如下所示的最小焦距和可用焦距,但没有帮助.如何控制焦距?
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 应该关闭.
https://github.com/pinguo-yuyidong/Camera2/blob/master/app/src/main/java/us/yydcdut/androidltest/ui/DisplayFragment.java
第 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中手动对焦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!