问题
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