I am building a scanner app, and trying to determine the "preview quality" from the preview callback of the camera. I want to customize the camera's `AUTO_FLASH_MODE` where it will be turned on if the environment is too dark.

How can I detect if there is a high average of dark pixels? This means (in preview) I am getting darkness and therefore need to turn on the camera's flash light.