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)
|
img = cv2.imread(fn)
|
||||||
else:
|
else:
|
||||||
sz = 4096
|
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)
|
img = np.zeros((sz, sz), np.uint8)
|
||||||
track = np.cumsum(np.random.rand(500000, 2)-0.5, axis=0)
|
track = np.cumsum(np.random.rand(500000, 2)-0.5, axis=0)
|
||||||
track = np.int32(track*10 + (sz/2, sz/2))
|
track = np.int32(track*10 + (sz/2, sz/2))
|
||||||
|
@ -49,13 +49,30 @@ def create_capture(source):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
try: fn = sys.argv[1]
|
import argparse
|
||||||
except: fn = 'synth:bg=../cpp/lena.jpg:noise=0.1'
|
|
||||||
|
|
||||||
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:
|
while True:
|
||||||
|
imgs = []
|
||||||
|
for i, cap in enumerate(caps):
|
||||||
ret, img = cap.read()
|
ret, img = cap.read()
|
||||||
cv2.imshow('img', img)
|
imgs.append(img)
|
||||||
|
cv2.imshow('capture %d' % i, img)
|
||||||
ch = cv2.waitKey(1)
|
ch = cv2.waitKey(1)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
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