From 9d4edc6c4af0daec4157aa373972bfa1ff149233 Mon Sep 17 00:00:00 2001 From: kris Date: Wed, 27 Feb 2019 14:10:39 +0000 Subject: [PATCH] Compute median frame similarity. This turns out not to be a great metric though, because it doesn't penalize artifacts like colour fringing, or diffs that persist across many frames. --- main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index cea0469..a3da57b 100644 --- a/main.py +++ b/main.py @@ -6,9 +6,9 @@ import opcodes import screen import video -MAX_OUT = 1 * 1024 * 1024 +MAX_OUT = 10 * 1024 * 1024 VIDEO_FPS = 30 -APPLE_FPS = 10 +APPLE_FPS = 15 def main(): @@ -16,6 +16,8 @@ def main(): "Computer Chronicles - 06x05 - The Apple II.mp4") bytes_out = 0 + sims = [] + out_frames = 0 s = video.Video(APPLE_FPS) screen_cls = screen.HGR140Bitmap @@ -57,14 +59,18 @@ def main(): bytes_out += len(stream) bytes_left = MAX_OUT - bytes_out + sim = screen.bitmap_similarity(im, bm) + sims.append(sim) + out_frames += 1 print("Frame %d, %d bytes, similarity = %f" % ( - idx, len(stream), screen.bitmap_similarity(im, bm))) + idx, len(stream), sim)) out.write(stream[:bytes_left]) if bytes_left <= 0: out.write(bytes(s.done())) break + print("Median similarity: %f" % sorted(sims)[out_frames//2]) if __name__ == "__main__":