Skip to content

Instantly share code, notes, and snippets.

@amol9
Created December 14, 2015 13:44
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save amol9/89579987949bfb0c651e to your computer and use it in GitHub Desktop.
A bash script using streamer and convert to detect the ambient room brightness using webcam.
#!/bin/bash
filename=capture.ppm
streamer -o $filename >/dev/null 2>&1
rgb=$(convert $filename -resize 1x1 txt:- | sed -n 2p | grep -Po "#\w+" | cut -c 2-)
if [[ 0x$rgb -lt 0x212121 ]]
then
echo yes
else
echo no
fi
rm $filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment