diff --git a/samples/python2/browse.py b/samples/python2/browse.py index 721fbaa83..579b0e814 100644 --- a/samples/python2/browse.py +++ b/samples/python2/browse.py @@ -16,7 +16,7 @@ if len(sys.argv) > 1: img = cv2.imread(fn) else: sz = 4096 - print 'generating %dx%d procudural image ...' % (sz, sz) + print 'generating %dx%d procedural image ...' % (sz, sz) img = np.zeros((sz, sz), np.uint8) track = np.cumsum(np.random.rand(500000, 2)-0.5, axis=0) track = np.int32(track*10 + (sz/2, sz/2)) diff --git a/samples/python2/video.py b/samples/python2/video.py index 762f01a84..3b5a98e79 100644 --- a/samples/python2/video.py +++ b/samples/python2/video.py @@ -49,13 +49,30 @@ def create_capture(source): if __name__ == '__main__': import sys - try: fn = sys.argv[1] - except: fn = 'synth:bg=../cpp/lena.jpg:noise=0.1' + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument('sources', nargs='*', default=['synth:bg=../cpp/lena.jpg:noise=0.1']) + parser.add_argument('-shotdir', nargs=1, default='.') + args = parser.parse_args() + print args - cap = create_capture(fn) + print 'Press SPACE to save current frame' + + caps = map(create_capture, args.sources) + shot_idx = 0 while True: - ret, img = cap.read() - cv2.imshow('img', img) + imgs = [] + for i, cap in enumerate(caps): + ret, img = cap.read() + imgs.append(img) + cv2.imshow('capture %d' % i, img) ch = cv2.waitKey(1) if ch == 27: break + if ch == ord(' '): + for i, img in enumerate(imgs): + fn = '%s/shot_%d_%03d.bmp' % (args.shotdir[0], i, shot_idx) + cv2.imwrite(fn, img) + print fn, 'saved' + shot_idx += 1