Starts adding ant script. Adds script allowing to create raw video from images

This commit is contained in:
2012-06-05 14:15:34 +02:00
parent d6e1965cbe
commit 7c969fd9b3
4 changed files with 84 additions and 2 deletions

28
build.xml Normal file
View File

@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<project name="FaceMovie build script" default="print" basedir=".">
<taskdef resource="pyAntTasks.properties"/>
<!-- Initialize properties and classpath -->
<target name="init">
<!-- Properties -->
<property name="src.dir" value="facemovie"/>
<property name="test.dir" value="test"/>
<!-- Time -->
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd" />
</tstamp>
</target>
<!-- -->
<target name="print" description="Just prints some information">
</target>
<target name="compile" depends="init" >
<py-compile dir="${src.dir}" pythonpath="${src.dir}" optimize="0"/>
</target>
</project>

View File

@@ -330,7 +330,8 @@ class FaceMovie(object):
height = self.height
frameSize = (width[0] + width[1], height[0] + height[1])
else:
frameSize = (self.dim_x, self.dim_y)
frameSize = (self.dim_x, self.dim_y)
print "Speed is set to %d fps" %(fps)
my_video = cv.CreateVideoWriter(filename,
fourcc,
fps,

View File

@@ -156,7 +156,7 @@ class Facemoviefier():
print "Saving output images :"
self.facemovie.save_faces(self.args['output'])
elif self.args['type'] == 'v':
print "Saving output video :"
print "Saving output video:"
self.facemovie.save_movie(self.args['output'], self.args['fps'])
if __name__ == '__main__':

53
test/raw_video.py Normal file
View File

@@ -0,0 +1,53 @@
"""
.. script:: raw_video
:platform: Unix, Windows
:synopsis: Aims at taking the same images used to create the FaceMovie, but using doind any processing.
This is used as an example to show the difference
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
"""
import sys
import os
import cv
root_folder = "../data/inputs/moi2"
out_name = "../data/output/raw.avi"
# fixed params
fourcc = cv.CV_FOURCC('C', 'V', 'I', 'D')
frameSize = (1280, 960)
fps = 3
# Processing
try:
os.path.exists(root_folder)
os.path.isdir(root_folder) # checking if folder exists
except : # find precise exception
print "ERROR : Source folder not found ! Exiting. . ."
sys.exit(0)
# just listing directory. Lets be more secure later
files = os.listdir(root_folder)
my_video = cv.CreateVideoWriter(out_name,
fourcc,
fps,
frameSize,
1)
# loading images, resizes image and populate the video
num_files = len(files)
inc = 0
for token in files :
inc += 1
guy_source = os.path.join(root_folder, token)
image = cv.LoadImage(guy_source)
out_image = cv.CreateImage(frameSize, image.depth, image.nChannels)# used in current bug solving.
cv.Resize(image, out_image)
print "Saving frame %d / %d" %(inc, num_files)
cv.WriteFrame(my_video, out_image)
print "Finished raw movie!"