Esempio n. 1
0
            video_filename = opt.output[:-3] + 'avi'
        else:
            video_filename = opt.output + '.avi'
    from cv import FOURCC
    from cv2 import VideoWriter
    movieWriter = VideoWriter(video_filename, FOURCC('U','2','6','3'),
                              20, (opt.length, opt.length), False)
    print 'Writing movie to ' + video_filename

# Number of dashes in complete progress bar
progress_bar_size = min(20, opt.steps)
steps_per_dash = opt.steps / progress_bar_size
print '['+' '*progress_bar_size+']\r[',
stdout.flush()

for step in xrange(1,opt.steps):
    lattice.step(opt.beta)
    if opt.movie:
        movieWriter.write((128*lattice.state).astype(sp.uint8))
    if step % steps_per_dash == 0:
        stdout.write('-')
        stdout.flush()
    fd.write(' '.join(str(d) for d in [lattice.up, lattice.updown]) + '\n')
if opt.steps % progress_bar_size == 0:
    stdout.write('-')
    stdout.flush()

stdout.write('\n')
fd.close()

Esempio n. 2
0
import scipy as sp
from lattice import Lattice
from sys import stdout

length = 512
fps = 20

from cv import FOURCC
from cv2 import VideoWriter
movieWriter = VideoWriter('freeze.avi', FOURCC('U','2','6','3'),
                          fps, (length, length), False)

lattice = Lattice(sp.random.random(size=(length, length)))
samples = fps*60
x = samples/10
for beta in sp.linspace(.01, 10, samples):
    movieWriter.write((128*lattice.state).astype(sp.uint8))
    lattice.step(beta)
    samples -= 1
    if samples % x == 0:
        stdout.write('-')
        stdout.flush()