Change CONTROL_AE_EXPOSURE_COMPENSATION propostional to seekbar progress in Camera2 API

 ̄綄美尐妖づ 提交于 2019-12-13 14:23:05

问题


I'm currently working on Androids Camera 2 API and my current problem is, that I cannot set the CONTROL_AE_EXPOSURE_COMPENSATION.

I want to exposure between -2 to 2.

Here is my code.

public void setExposure(double exposureAdjustment) {
    Range<Integer> range1 = mCameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
    int minExposure = range1.getLower();
    int maxExposure = range1.getUpper();

    float newCalculatedValue = 0;
    if (exposureAdjustment >= 0) {
        newCalculatedValue = (float) (minExposure * exposureAdjustment);
    } else {
        newCalculatedValue = (float) (maxExposure * -1 * exposureAdjustment);
    }

    try {
        CaptureRequest captureRequest = mPreviewRequestBuilder.build();
        mPreviewSession.setRepeatingRequest(mPreviewRequest,
                mCaptureCallback, mBackgroundHandler);
        mPreviewRequestBuilder.set(captureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, (int) newCalculatedValue);
        mPreviewSession.capture(captureRequest, mCaptureCallback, mBackgroundHandler);

        Log.v("cascascasc", exposureAdjustment + " : " + newCalculatedValue);

    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

On Seekbar change listener i call

    exposure_seekbar.setMin(-2);
    exposure_seekbar.setMax(2);
    exposure_seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {

            if (b) {
                mCamera2Fragment.setExposure((double)i);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

来源:https://stackoverflow.com/questions/53514188/change-control-ae-exposure-compensation-propostional-to-seekbar-progress-in-came

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!