diff --git a/test/fix_crop.py b/test/fix_crop.py index 74726e2..0365f93 100644 --- a/test/fix_crop.py +++ b/test/fix_crop.py @@ -2,12 +2,41 @@ import os import cv + + +def resizes_for_video_codec(frameSize): + """ + Searches for the closest couple of frameSize so that width*height is a multiple of 4 to avoid weird image encoding. + """ + try: + x,y = frameSize + except ValueError: + print "ERROR: unknown format for frameSize " + return (0, 0) + + if not(isinstance(x, int)) or not(isinstance(x, int)): + print "ERROR: method expects two integers" + return (0, 0) + + while ((x * 3) % 4) != 0: + x += 1 + + print frameSize + print x, y + + return (x, y) + in_dir = "../data/inputs/sample-test" out = "output.avi" # loading images, create Guys and store it into guys -frameSize = (652, 498) +frameSize = (1257, 499) + + +frameSize = resizes_for_video_codec(frameSize) + + #frameSize = (453, 325) fourcc = cv.CV_FOURCC('F', 'M', 'P', '4') my_video = cv.CreateVideoWriter(out,