Android: detect brightness (amount of light) in phone's surroundings using the camera?

后端 未结 5 983
小蘑菇
小蘑菇 2020-12-01 08:38

The following applies to the Android operating system.

I am trying to estimate how dark (or light) it is in the room where the phone is located using the camera.

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 09:24

    My response may be too incomplete for an answer, but I like the formatting here.

    Additionally, my answer is not facetious, so don't stop reading right away.

    Of course, first you'll have to take a picture. Then you'll have to define 'brightness'. I don't have the algorithm to do so, but I'm guessing something like that has already been done. Maybe something like :

    Determine which pixel values are bright, which are dark and which are in between (and each of them can have a variable amount of brightness). You'll then have to apply that algorithm to your photograph to get a brightness value.

    Yes, this is a very short (35,000 foot) view of the problem, but it should give you some ideas about where to start.

    [edit]
    Here is a place to start (the android documentation for sensors)
    [/edit]

提交回复
热议问题