Camera2 API is a recently released API provided by Google for lollipop (API Level 21). In one of our Android project, client wanted that his application should capture image with custom settings for Focus, Flash, Exposure and ISO by using this latest Camera2 API.
Issues were faced while making some combinations of settings and image preview darkness when ISO is manually set. Due to Camera2 API recent release, there was limited guidance available on forums/blog.
We had different options available to set Flash modes either as ON/Auto/Redeye/Always ON or set exposure value manually. For this, Exposure Mode should be set as ON. But if ISO values had to be set manually, then Exposure Mode should be set as OFF.
Image preview darkness was due to SENSOR_EXPOSIRE_TIME. Whenever Exposure Mode is set as OFF, image preview becomes dark and we should manually control Sensor Exposure Time, Sensor Frame Duration and Sensor Sensitivity(ISO value). But at that time, we were only setting Sensor Sensitivity (ISO value) regardless of whatever Sensor Exposure Time and Sensor Frame Rate values would be. To get the preview, we had to set at least Sensor Exposure Time. What time should be set to get the preview? We found the solution and saved the last good value for Sensor Exposure. We set that value when ISO had to be set manually.