Changed black frame detection to average-luma based. Lowered threshold.

Changed black frame detection to average-luma based. Lowered threshold. Tested it with a fake webcam and with an external webcam that I covered totally or partially with my finger. Worked as intended.

Also some minor things.
You skip the first pixel? Intentional? do you want to avoid exiting the loop based only on one non-black pixel?