multiple cameras and frame saving in video.py
This commit is contained in:
parent
fac611337f
commit
787fe6a93f
@ -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))
|
||||
|
@ -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
|
||||
|
||||
cap = create_capture(fn)
|
||||
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
|
||||
|
||||
print 'Press SPACE to save current frame'
|
||||
|
||||
caps = map(create_capture, args.sources)
|
||||
shot_idx = 0
|
||||
while True:
|
||||
imgs = []
|
||||
for i, cap in enumerate(caps):
|
||||
ret, img = cap.read()
|
||||
cv2.imshow('img', img)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user