googlearchive/android-Camera2Video

The preview is very dark

Closed this issue · 2 comments

The preview is very dark

I resolved this preview is dark issues by doing these steps.
//set brightness
mPreviewBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, getRange());

and add this method

/**
 * An {@link CameraCharacteristics} method for camera preview not dark
 */

private Range<Integer> getRange() {
    CameraCharacteristics chars = null;
    CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
    try {
        String cameraId = manager.getCameraIdList()[1];
        chars = manager.getCameraCharacteristics(cameraId);
        Range<Integer>[] ranges = chars.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
        Range<Integer> result = null;
        for (Range<Integer> range : ranges) {
            int upper = range.getUpper();
            // 10 - min range upper for my needs
            if (upper >= 10) {
                if (result == null || upper < result.getUpper().intValue()) {
                    result = range;
                }
            }
            Log.e("Avaliable frame fps :", "" + range);
        }
        if (result == null) {
            result = ranges[0];
        }

        Log.e("frame fps :", "" + result);
        return result;
    } catch (CameraAccessException e) {
        e.printStackTrace();
        return null;
    }
}

this will resolve by issues.
Thanks

This sample has been migrated to a new location so we can allow Pull Requests (check README for more information).

As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.

If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!