#!/usr/bin/env python

from faces import *
from math import *
import os 
import sys

if sys.argv[1] == "-h":
	print("anim_pca pcafile width height starteigenface endeigenface gain frames")
	exit(0)

pca = load_pca(sys.argv[1])
w=int(sys.argv[2])
h=int(sys.argv[3])

for i in range(0,int(sys.argv[7])):
	img = smp.toimage( make_eigenfaces_image(w,h,pca,int(sys.argv[4]),int(sys.argv[5]),float(sys.argv[6])*sin(i*0.1))) 
	filename = "frames/out-%0.5d.jpg"%(i)
	print filename
	img.save(filename)

os.system("mencoder mf://frames/*.jpg -oac lavc -ovc lavc -of mpeg -ofps 25 -o out.avi")
