|
|
|
@ -26,7 +26,7 @@ def main(output_file, videos, maxlen=900):
|
|
|
|
|
subprocess.check_call([
|
|
|
|
|
'ffmpeg', '-hide_banner',
|
|
|
|
|
'-i', video,
|
|
|
|
|
'-r', '1',
|
|
|
|
|
'-r', '2',
|
|
|
|
|
os.path.join(rowdir, 'frame%08d.png'),
|
|
|
|
|
])
|
|
|
|
|
for i, frame in enumerate(sorted(os.listdir(rowdir))):
|
|
|
|
@ -43,10 +43,14 @@ def main(output_file, videos, maxlen=900):
|
|
|
|
|
#avg_color = (0, 0, 0)
|
|
|
|
|
#count = 0
|
|
|
|
|
#for color in frame_im.getdata():
|
|
|
|
|
# if color != [0,0,0]:
|
|
|
|
|
# if color != (0,0,0):
|
|
|
|
|
# avg_color = tuple(a + b for a, b in zip(avg_color, color))
|
|
|
|
|
# count += 1
|
|
|
|
|
#avg_color = tuple(a / count for a in avg_color)
|
|
|
|
|
#if count > 0:
|
|
|
|
|
# avg_color = tuple(a / count for a in avg_color)
|
|
|
|
|
#else:
|
|
|
|
|
# avg_color = (0, 0, 0)
|
|
|
|
|
#image.putpixel((i, row), tuple(avg_color))
|
|
|
|
|
|
|
|
|
|
## true avg using numpy
|
|
|
|
|
#avg_per_row = numpy.average(cv2.imread(filepath), axis=0)
|
|
|
|
@ -58,12 +62,12 @@ def main(output_file, videos, maxlen=900):
|
|
|
|
|
non_black = im[im.sum(axis=2) != 0]
|
|
|
|
|
avg = numpy.average(non_black, axis=0)
|
|
|
|
|
try:
|
|
|
|
|
color = tuple(map(int, avg))
|
|
|
|
|
# note numpy flips the RGB values to BGR for some reason, so flip back
|
|
|
|
|
color = tuple(map(int, avg))[::-1]
|
|
|
|
|
except ValueError: # avg is NaN because all pixels black
|
|
|
|
|
color = (0, 0, 0)
|
|
|
|
|
image.putpixel((i, row), color)
|
|
|
|
|
|
|
|
|
|
#image.putpixel((i, row), tuple(avg_color))
|
|
|
|
|
|
|
|
|
|
rmtree(rowdir)
|
|
|
|
|
|
|
|
|
|