How to write code to detect low light condition on preview screen in client side using Java script, jQuery, html, css

In the preview screen the camera will be on based on image captured by the camera it should detect whether the person is sitting on low light condition or not and the client needs to receive a notification regarding it.