From 7c969fd9b3f4748bed980191dbd878f1c2f5ea52 Mon Sep 17 00:00:00 2001 From: Julien Lengrand-Lambert Date: Tue, 5 Jun 2012 14:15:34 +0200 Subject: [PATCH] Starts adding ant script. Adds script allowing to create raw video from images --- build.xml | 28 ++++++++++++++++++++ facemovie/Facemovie.py | 3 ++- facemovie/Facemoviefier.py | 2 +- test/raw_video.py | 53 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 build.xml create mode 100644 test/raw_video.py diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..f190b2e --- /dev/null +++ b/build.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/facemovie/Facemovie.py b/facemovie/Facemovie.py index 8eb3b03..d24fe1e 100644 --- a/facemovie/Facemovie.py +++ b/facemovie/Facemovie.py @@ -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, diff --git a/facemovie/Facemoviefier.py b/facemovie/Facemoviefier.py index c01a154..7e86709 100644 --- a/facemovie/Facemoviefier.py +++ b/facemovie/Facemoviefier.py @@ -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__': diff --git a/test/raw_video.py b/test/raw_video.py new file mode 100644 index 0000000..3d3aaad --- /dev/null +++ b/test/raw_video.py @@ -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 + +""" +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!" \ No newline at end of file