Created
May 1, 2019 13:04
-
-
Save campanalbero/0d7298e746e8d02414ed5ca222ea3407 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO shebang and exec flag | |
import cv2 | |
import glob | |
import numpy as np | |
import os | |
import sys | |
"""calc diff compared with next jpg. | |
usage: python diff.py PATH | |
""" | |
# e.g. '/home/suzuki/2018-06-21/original/13/' | |
path = sys.argv[-1] | |
files = sorted(glob.glob(path + '*.jpg')) | |
count = 0 | |
minimum = 1920 * 1080 * 255 | |
print(path + 'mask.png') | |
mask = cv2.imread('/home/suzuki/mask.png', cv2.IMREAD_GRAYSCALE) | |
curr = cv2.imread(files[-1], cv2.IMREAD_GRAYSCALE) * mask | |
# TODO if-condition 3600 | |
group_num = 3600 / (len(files) - 3600) | |
print("path, diff value compared with prev img") | |
for f in files: | |
prev = curr | |
curr = cv2.imread(f, cv2.IMREAD_GRAYSCALE) * mask | |
diff = cv2.absdiff(prev, curr) | |
diff_sum = diff.sum() | |
print(f + ', ' + str(diff_sum)) | |
if minimum > diff_sum: | |
minimum = diff_sum | |
path = f | |
count = count + 1 | |
if count > group_num: | |
dest = os.path.dirname(path) + "/../unused/" + os.path.basename(path) | |
print(path + ", " + dest + ", was moved") | |
os.rename(path, dest) | |
minimum = 1920 * 1080 * 255 | |
count = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment