/[escript]/trunk/pyvisi/py_src/movie.py
ViewVC logotype

Diff of /trunk/pyvisi/py_src/movie.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1194 by jongui, Thu Jun 14 05:53:49 2007 UTC revision 1197 by jongui, Mon Jun 18 02:08:34 2007 UTC
# Line 1  Line 1 
1  """  """
2  @author: John NGUI  @var __author__: name of author
3    @var __copyright__: copyrights
4    @var __license__: licence agreement
5    @var __url__: url entry point on documentation
6    @var __version__: version
7    @var __date__: date of the version
8  """  """
9    
10    __author__="John Ngui, john.ngui@uq.edu.au"
11    __copyright__="""  Copyright (c) 2006 by ACcESS MNRF
12                        http://www.access.edu.au
13                    Primary Business: Queensland, Australia"""
14    __license__="""Licensed under the Open Software License version 3.0
15                 http://www.opensource.org/licenses/osl-3.0.php"""
16    __url__="http://www.iservo.edu.au/esys"
17    __version__="$Revision$"
18    __date__="$Date$"
19    
20    
21  from esys.pyvisi.constant import ImageFormat  from esys.pyvisi.constant import ImageFormat
22  from os import system  from os import system
23    
# Line 23  class Movie: Line 39  class Movie:
39    
40          self.__parameter_file = parameter_file          self.__parameter_file = parameter_file
41    
42      def makeMovie(self, input_directory, first_image, last_image, movie):  
43        def imageRange(self, input_directory, first_image, last_image):
44          """          """
45          Coordinate the generation of the movie.          The image range from which the movie is to be generated from.
46    
47          @type input_directory: String          @type input_directory: String
48          @param input_directory: Directory in which the series of images can          @param input_directory: Directory in which the series of images can
# Line 34  class Movie: Line 51  class Movie:
51          @param first_image: First image name (including the extension)          @param first_image: First image name (including the extension)
52          @type last_image: String          @type last_image: String
53          @param last_image: Last image name (including the extension)          @param last_image: Last image name (including the extension)
         @type movie : String  
         @param movie: Movie name (including the extension)  
54          """          """
55    
56            # Keeps track whether an image range or image list was provided as
57            # the source for generating the movie.
58            self.__image_range_used = True
59          self.__input_directory = input_directory          self.__input_directory = input_directory
60          self.__first_image = first_image          self.__first_image = first_image
61          self.__last_image = last_image          self.__last_image = last_image
         self.__movie = movie  
62    
63          self.__splitInput()          self.__splitInput()
64          self.__retrieveFirstImageDetails()          self.__retrieveFirstImageDetails()
65          self.__retrieveLastImageDetails()          self.__retrieveLastImageDetails()
66          self.__retrieveConversionCommand()          self.__retrieveConversionCommand()
67    
68        def imageList(self, input_directory, image_list):
69            """
70            The image list from which the movie is to be generated from.
71    
72            @type input_directory: String
73            @param input_directory: Directory in which the series of images can
74                    be found
75            @type image_list: List
76            @type image_list: List of images name
77            """
78    
79            self.__image_range_used = False
80            self.__input_directory = input_directory
81            self.__images = ""
82    
83            self.__first_image = image_list[0] # Get first image in the list.      
84            self.__splitInput()
85            self.__retrieveConversionCommand()
86    
87            for i in image_list:
88                self.__images += i  + '\n'
89    
90        def makeMovie(self, movie):
91            """
92            Coordinate the generation of the movie.
93    
94            @type movie : String
95            @param movie: Movie name (including the extension)
96            """
97    
98            self.__movie = movie
99          self.__generateParameterFile()          self.__generateParameterFile()
100    
101          # If a parameter file name was not specified, then the default file          # If a parameter file name was not specified, then the default file
# Line 70  class Movie: Line 119  class Movie:
119          self.__first_image = \          self.__first_image = \
120                  self.__first_image.rstrip('.' + self.__image_format)                  self.__first_image.rstrip('.' + self.__image_format)
121    
122          # Last image name.          if(self.__image_range_used == True):
123          self.__last_image = \              # Last image name.
124                  self.__last_image.rstrip('.' + self.__image_format)              self.__last_image = \
125                        self.__last_image.rstrip('.' + self.__image_format)
   
   
         #self.__image_format = self.__first_image.split('.')[1]  
         # First image name.  
         #self.__first_image = self.__first_image.split('.')[0]  
         # Last image name.  
         #self.__last_image = self.__last_image.split('.')[0]  
126    
127      def __retrieveFirstImageDetails(self):      def __retrieveFirstImageDetails(self):
128          """          """
# Line 112  class Movie: Line 154  class Movie:
154                  self.__last_image_number = \                  self.__last_image_number = \
155                          self.__last_image_number + self.__last_image[i]                          self.__last_image_number + self.__last_image[i]
156    
         # The last image number is deducted by one. This allows the user  
         # to use the same image range when generating a movie as the  
         # ones used for the for-loop.  
         #self.__last_image_number = unicode(int(self.__last_image_number) - 1)  
           
157      def __retrieveConversionCommand(self):      def __retrieveConversionCommand(self):
158          """          """
159          Retrieve the conversion command (depending on the image format)          Retrieve the conversion command (depending on the image format)
160          required by the 'ppmtompeg' command.          required by the 'ppmtompeg' command.
161          """          """
162          print "-----", self.__image_format  
163          if(self.__image_format.endswith(ImageFormat.JPG)):          if(self.__image_format.endswith(ImageFormat.JPG)):
164              self.__command = 'jpeg'              self.__command = 'jpeg'
165          elif(self.__image_format.endswith(ImageFormat.BMP)):          elif(self.__image_format.endswith(ImageFormat.BMP)):
# Line 142  class Movie: Line 179  class Movie:
179          Write the list of parameters into the file.          Write the list of parameters into the file.
180          """          """
181    
182            if(self.__image_range_used == True): # Image range was provided.
183                input = self.__image_prefix + '*.' + self.__image_format + ' [' + \
184                        self.__first_image_number + '-' + \
185                        self.__last_image_number + ']\n'
186            else: # Image list was provided
187                input = self.__images
188    
189          parameter_file = open(self.__parameter_file, 'w')          parameter_file = open(self.__parameter_file, 'w')
190    
191          parameter_file.write('PATTERN IBBPBBPBBPBBPBBP\n' +          parameter_file.write('PATTERN IBBPBBPBBPBBPBBP\n' +
# Line 152  class Movie: Line 196  class Movie:
196              'SLICES_PER_FRAME 10\n' +              'SLICES_PER_FRAME 10\n' +
197              'INPUT_DIR ' + self.__input_directory + '\n' +              'INPUT_DIR ' + self.__input_directory + '\n' +
198              'INPUT\n' +              'INPUT\n' +
199              self.__image_prefix + '*.' + self.__image_format + ' [' + \              input +
                     self.__first_image_number + '-' + \  
                     self.__last_image_number + ']\n'  
200              'END_INPUT\n' +              'END_INPUT\n' +
201              'PIXEL HALF\n' +              'PIXEL HALF\n' +
202              'RANGE 10\n' +              'RANGE 10\n' +

Legend:
Removed from v.1194  
changed lines
  Added in v.1197

  ViewVC Help
Powered by ViewVC 1.1.26