googlearchive / android-Camera2Video

Migrated:
https://github.com/android/camera
Apache License 2.0
1.21k stars 568 forks source link

The preview is very dark #71

Closed Sejen27 closed 5 years ago

Sejen27 commented 6 years ago

The preview is very dark

tarunasharma03 commented 5 years ago

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

codingjeremy commented 5 years ago

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!