The Video (part 3)

This is the third post in the series, the first and second are elsewhere.

In preparation for the next hack night I have been playing around with multiple angle videos.
I created short set of images using motion with three cameras. I then used a python script to sew the images together. The script converts a directory listing of files (with time stamps) into a list of lists of filenames to pass into montage to make the indervidual images into frames for the video.

The algorithm is rather suboptimal, it just chooses the next lowest lowest image from the list. If any one has any ideas on how to improve this please leave a comment. More details after the break..


Camera1			Camera2			Camera3
1220195243-00.jpg	1220195241-01.jpg	1220195232-01.jpg
1220195244-01.jpg	1220195242-01.jpg	1220195257-01.jpg
1220195306-01.jpg	1220195243-01.jpg	1220195304-01.jpg
1220195308-00.jpg	1220195307-01.jpg	1220195312-01.jpg


{{ 1220195243-00.jpg ,  1220195241-01.jpg ,  1220195232-01.jpg },
 { 1220195243-00.jpg , *1220195242-01.jpg*,  1220195232-01.jpg },
 { 1220195243-00.jpg , *1220195242-01.jpg*,  1220195232-01.jpg },
 {*1220195244-01.jpg*,  1220195242-01.jpg ,  1220195232-01.jpg },

Every triplet in this list is then used to generate a call to montage, to stitch the photos together.

montage -geometry +0+0 1220195243-00.jpg 1220195241-01.jpg /
1220195232-01.jpg 001.jpg

to create a frame like this…

from collections import deque
import getopt
import os
import subprocess
import sys
def doit():
        opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
    except getopt.error, msg:
        print msg
        print "for help use --help"
    print ("opts", opts)
    print ("args", args)
    images = []
    paths = args
    for path in paths:
        files = deque(os.listdir("./" + path + "/"))
        print files
    stillRunning = range(0, len(images))
    c = []
    n = []
    for index in stillRunning:
    x = []
    print "c=", c, "\nn=", n, "\nx=", x
    while len(stillRunning) > 0:
        done = False
        for t in stillRunning:
            if n[t] <= min (n):
                c[t] = n[t]
                if len(images[t]) > 0:
                    n[t] = images[t].popleft()
                    print (stillRunning)
                    n[t] = "NULL"
                done = True

        if done:
            print ("fuck", len(x), c, n)

    print ""
    count = 0
    for xx in x:
        command = ['montage', '-geometry', '+0+0']
        for i in range (0, len(paths)):
            command.append('./' + paths[i] + '/' + xx[i])
        command.append('./output/' + str(count).zfill(3) + ".jpg")
        print "\n", xx
        print "Building frame", count +1, "of", len(x)
        count = count + 1
if __name__ == '__main__':

About Mex

Computer science PHD student from Canterbury. Interested in concurrency, mostly CSP and Occam-pi.
This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>