RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 405 forks source link

Camera 1 dark preview #139

Closed JPLITPeople closed 6 years ago

JPLITPeople commented 6 years ago

Some devices are showing a very dark preview comparing to stock camera (specially on low light environments).

Aparently the problem is from the devices and not Fotoapparat. The issue seems to be the Fps range reported. The problematic devices show the same number for lowest and highest range. (ex: [15000,15000] while choosing rangeWithHighestFps or rangeWithLowestFps.

The solution for me was to add a new function:

public static SelectorFunction<Collection<Range<Integer>>, Range<Integer>> customFpsRange() {
    return new SelectorFunction<Collection<Range<Integer>>, Range<Integer>>() {
        @Override
        public Range<Integer> select(Collection<Range<Integer>> items) {
            if (items.isEmpty()) {
                return null;
            }

            ArrayList<Range<Integer>> rangeArraylist= new ArrayList<>();
             for (Range<Integer> range : items) {

                if (range.highest().intValue() != range.lowest().intValue()) {

                    rangeArraylist.add(range);
                }

            }

            if (!rangeArraylist.isEmpty()) {

                return Collections.max(rangeArraylist, COMPARATOR_BY_BOUNDS);
            } else {

                return Collections.max(items, COMPARATOR_BY_BOUNDS);
            }

        }
    };
}

This gets all the ranges that have different lowest and highest values, and chooses the max from it.

This fixed most my problems with it. Altough some devices were still a bit dark, so i had to play a bit with the sensorSensitivitySelectors. Giving the lowest value would still make some devices a bit dark, but nothing compared to before

Diolor commented 6 years ago

This is very interesting @JPLITPeople ! Do you have some example devices which have an obvious (easily reproducible) issue?

I know that in Nexus 6P e.g. facebook messenger produces darker images than the stock camera app.

JPLITPeople commented 6 years ago

I've tested on:

But you can test it on a dark or really low light environment, switching from fotoapparat camera to stock camera and check if the image is darker. Altough not all devices will be really dark, you can spot the diferences when the "bug" occurs.

I'm using ISO around 400 as well

EDIT: Testing now with samsung S8 EDIT: S8 is the perfect example for this. On low light conditions the preview is pitch black! Using the tweak i mentioned gets the image perfectly visible (with lowestSensorSensitivity()), and it gets really perfect (as the stock camera) using ISO value 400

Diolor commented 6 years ago

Brain dump/todo: maybe we can improve our fps selectors by prioritizing non-fixed rates than fixed ones

Diolor commented 6 years ago

Ok this is a bug in our selectors. Non-fixed rates must be selected earlier than fixed ones

Diolor commented 6 years ago

New selectors added in v2