diff --git a/.gitmodules b/.gitmodules index c8f8431..4833330 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,3 +11,6 @@ [submodule "bash/liquidprompt"] path = bash/liquidprompt url = https://github.com/nojhan/liquidprompt +[submodule "cron/blackcheck"] + path = cron/blackcheck + url = https://github.com/Stunkymonkey/blackcheck.git diff --git a/cron/blackcheck b/cron/blackcheck new file mode 160000 index 0000000..fb5af1f --- /dev/null +++ b/cron/blackcheck @@ -0,0 +1 @@ +Subproject commit fb5af1f8bb72c987c49c77ea8ed558196765f011 diff --git a/cron/blackcheck.py b/cron/blackcheck.py deleted file mode 100755 index 1a41758..0000000 --- a/cron/blackcheck.py +++ /dev/null @@ -1,41 +0,0 @@ -from PIL import Image -from optparse import OptionParser -# import sys - -parser = OptionParser() -parser.add_option("-q", "--quiet", action="store_false", dest="verbose", - default=True, help="don't print status messages to stdout") -parser.add_option("-i", "--image", type="string", dest="imagename", - help="Name of Image") -parser.add_option("-d", "--diff", type="string", dest="diff", - default=0, help="maximum difference between Red, Green, Blue") - -(options, args) = parser.parse_args() - -if (options.imagename is None): - parser.error("no image entered") - -diff = int(options.diff) -img_path = options.imagename - - -def is_grey_scale(img_path): - try: - im = Image.open(img_path).convert('RGB') - except (FileNotFoundError): - print ("Image not found") - quit() - w, h = im.size - for i in range(w): - for j in range(h): - r, g, b = im.getpixel((i, j)) - if ((abs(r - g) > diff) & - (abs(r - b) > diff) & - (abs(b - g) > diff)): - return False - return True - -if (bool(options.verbose) == False): - is_grey_scale(img_path) -else: - print (is_grey_scale(img_path)) diff --git a/cron/blackcheck.py b/cron/blackcheck.py new file mode 120000 index 0000000..a16ef83 --- /dev/null +++ b/cron/blackcheck.py @@ -0,0 +1 @@ +/home/felix/code/python/blackcheck/blackcheck.py \ No newline at end of file diff --git a/cron/webcam.sh b/cron/webcam.sh index 95564b8..4e0f0c7 100755 --- a/cron/webcam.sh +++ b/cron/webcam.sh @@ -7,7 +7,7 @@ basename=$(dirname $(readlink -f $0)) mkdir -p $path streamer -q -f jpeg -s $size -o $path/$now.jpeg -r 1 -grey="$(python3 $basename/blackcheck.py -i $path/$now.jpeg -d 10)" +grey="$($basename/blackcheck/blackcheck.py -i $path/$now.jpeg -d 10)" if [ "$grey" = "True" ] ; then mv $path/$now.jpeg $path/black/$now.jpeg fi