Search code examples
androidsettingsisoandroid-camera2

Change Camera Settings for the Camera2 API android


I am using the android-camera2-secret-picture-taker and getting the image which is dark and not able to change the whiteblance in capture builder. Here is what changing I have made to capturebuilder:

/**Settings for Camera*/ // captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO); captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation());

    /**HDR*/
        captureBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_HDR);

    /**Settings for Flash*/
        captureBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);

captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);

/**for White Balance */
        captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_AUTO));

//for incandescent
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_INCANDESCENT);
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_INCANDESCENT));
//        captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, CameraCapabilities.colorTemperature(Integer.parseInt(awbMode)));

//for daylight
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_DAYLIGHT);
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_DAYLIGHT));
        }

//for fluorescent
captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_FLUORESCENT);
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_FLUORESCENT));}

//for cloudy
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.CONTROL_AWB_MODE_CLOUDY_DAYLIGHT);
            captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, colorTemperature(CaptureRequest.CONTROL_AWB_MODE_CLOUDY_DAYLIGHT));

/**For ISO*/
    captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
    CameraCharacteristics mCameraCharacteristics = characteristics;
    List keys_list = characteristics.getKeys();
    Range<Integer> range2 = characteristics.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
    int iso = ((200 * (200 - 100)) / 100 + 100);
    if (range2 != null) {
        int max1 = range2.getUpper();//10000
        int min1 = range2.getLower();//100
        iso = ((max1 * (max1 - min1)) / 100 + min1);
    }
    captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, iso);

I am not able to change the brightness, and other settings except the FlashMode.


Solution

  • I believe you are looking for "Auto Exposure" since you're talking about brightness. Therefore, I would suggest you to use:

    captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 4);
    // play around with the "4" which is the amount of brightness you want compensate by.