相机预览会话setRepeatingRequest焦点问题,仅关注第一次ontouch

时间:2015-10-26 21:28:56

标签: android android-activity camera touch ontouch

我有一个纹理视图,我已经实现了ontouch监听器,我希望当我触摸显示器以便能够聚焦时,但是在设置setRepeatingRequest来构建显示器时出现问题,它只在我触摸时第一次聚焦,之后关注我可以触摸100x但仍然没有效果,我想在对焦和拍摄时启用闪光但闪光灯一直保持在相机不对焦,请帮助我,我在这个任务中被困5天!

这是我的代码:      // meteringRectangleArr是我可以聚焦(测量)的区域

    mPreviewCaptureRequestBuilder.set(
                    CaptureRequest.CONTROL_AF_TRIGGER,
                    CaptureRequest.CONTROL_AF_TRIGGER_CANCEL);

                mPreviewCaptureRequestBuilder.set(
                        CaptureRequest.CONTROL_AF_REGIONS,
                        meteringRectangleArr);

                mPreviewCaptureRequestBuilder.set(
                    CaptureRequest.CONTROL_AE_REGIONS,
                        meteringRectangleArr);

                mPreviewCaptureRequestBuilder.set(CaptureRequest.CONTROL_MODE,
                        CaptureRequest.CONTROL_MODE_AUTO);

                mPreviewCaptureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                        CaptureRequest.CONTROL_AF_MODE_AUTO);

                mPreviewCaptureRequestBuilder.set(
                        CaptureRequest.CONTROL_AF_TRIGGER,
                        CaptureRequest.CONTROL_AF_TRIGGER_START);

                if(flash_value == 1){
                    flash_startime = System.currentTimeMillis();
                    updateFlashingView();
                    mPreviewCaptureRequestBuilder.set(
                            CaptureRequest.FLASH_MODE,
                            CaptureRequest.FLASH_MODE_SINGLE);
                }

                else if (flash_value == 0){
                    mPreviewCaptureRequestBuilder.set(
                            CaptureRequest.FLASH_MODE,
                            CaptureRequest.FLASH_MODE_OFF);
                }

                try {

                    mCameraCaptureSession.setRepeatingRequest(
                        mPreviewCaptureRequestBuilder.build(),
                        null, mBackgroundHandler);

                } catch (CameraAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

1 个答案:

答案 0 :(得分:0)

删除它:

mPreviewCaptureRequestBuilder.set(
                        CaptureRequest.CONTROL_AF_TRIGGER,
                        CaptureRequest.CONTROL_AF_TRIGGER_START);

你应该只使用mCameraCaptureSession.capture调用CONTROL_AF_TRIGGER_START一次。

我将google's Camera2Basic example分支并将其更改为使用CaptureRequest.CONTROL_AF_MODE_AUTO而不是CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE

您可以从git中获取项目并查看其工作原理 - https://github.com/pinhassi/android-Camera2Basic