[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30859] branches/soc-2010-leifandersen/ tests/render/run.py: 1.

Leif Andersen leif.a.andersen at gmail.com
Thu Jul 29 03:45:34 CEST 2010


Revision: 30859
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30859
Author:   leifandersen
Date:     2010-07-29 03:45:32 +0200 (Thu, 29 Jul 2010)

Log Message:
-----------
1.  The code cleaning added from last commit (which didn't get commited)

2.  Told blender to only render every 15 frames of animation...although it doesn't seem to be doing it yet.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/tests/render/run.py

Modified: branches/soc-2010-leifandersen/tests/render/run.py
===================================================================
--- branches/soc-2010-leifandersen/tests/render/run.py	2010-07-29 01:29:42 UTC (rev 30858)
+++ branches/soc-2010-leifandersen/tests/render/run.py	2010-07-29 01:45:32 UTC (rev 30859)
@@ -48,9 +48,6 @@
     diff_sum = None
     pixel_range = None
     difference = None
-    good_hash = None
-    test_hash = None
-    diff_hash = None
     message = ""
     ID = 'Image'
     mode = ''
@@ -62,17 +59,6 @@
         self.test_hash = -1
         self.diff_hash = -1
 
-    def setup_hash(self, blend_path, good_hash, test_path):
-        '''Used for setting up the case for the purpose of a hash test
-           blend_path: the  path to the blend file for the case
-           good_hash: An int containing the good hash of the case
-           test_path: the path for the output of the test when it's rendered'''
-        self.name = os.path.split(blend_path)[1]
-        self.good_hash = good_hash
-        self.blend_path = blend_path
-        self.test_path = test_path
-        self.mode = 'Hash'
-
     def setup_image(self, blend_path, good_path, test_path):
         '''Used for setting up the case for the purpose of a image comparison test
            blend_path: the  path to the blend file for the case
@@ -84,18 +70,6 @@
         self.test_path = test_path
         self.mode = 'Image'
 
-    def generate_hash(self, image):
-        '''Designed mainly for internal use, but can be used for external purposes if needed
-           Generates a hash out of a given image
-           image: The image that the hash will be made from
-           returns: The calculated hash'''
-        hash = 0
-        for i in range(0,image.size[0]):
-            for j in range(0, image.size[1]):
-                p = image.getpixel((i,j))
-                hash+= p[0] + p[1] + p[2]
-        return hash
-
     def get_images(self):
         '''Gets the good image, and test image (which assumes it's rendered), based on their
            paths.  Then creates a diff image out of the two other images.  If the images
@@ -176,38 +150,6 @@
         finally:
             return self.passed
 
-    def hash_test(self):
-        '''Performs the hash test on the image in case that the testcase is being used as a hashtest.
-           If the setup_image method was used rather than the setup_hash method, the test attempts to generate
-           a hash based on that image.  It assumes that the test image has been rendered
-           The status of the test passing can be found in the passed field.
-           This method changes the value of the diff paths to the actual diff paths.
-           returns:  Whether or not the test passed'''
-           
-           ### TODO, rewrite...bad code ###
-        if test_image == None:
-            try:
-                test_image = Image.open(self.test_path)
-            except IOError:
-                self.passed = False
-        if test_image != None:
-            if self.good_hash == None:
-                if good_image != None:
-                    self.good_hash = self.generate_hash(good_image)
-                else:
-                    self.message = 'No Good Hash given, or Good Image given'
-                    self.passed = False
-                    return
-            if self.test_hash == None:
-                self.test_hash = self.generate_hash(test_image)
-            if self.pixel_count == None:
-                self.pixel_count = test_image.size[0] * test_image.size[1]
-            self.diff_hash = abs(self.test_hash - self.good_hash)
-            if self.diff_hash < self.pixel_count/10:
-                self.passed = True
-            else:
-                self.passed = False
-
     def save_diff(self, output_path):
         '''Saves the diff image of the testcase to output_path
            output_path: The path to save the diff image'''
@@ -255,23 +197,6 @@
         self.test_hash = -1
         self.diff_hash = -1
 
-    def setup_hash(self, blend_path, good_hash, test_path):
-        '''Used for setting up the case for the purpose of a hash test
-           blend_path: the  path to the blend file for the case
-           good_hash: An int containing the good hash of the case
-           test_path: the path for the output folder of the test when it's rendered'''
-        self.name = os.path.split(blend_path)[1]
-        self.good_hash = good_hash
-        self.blend_path = blend_path
-        for imagename in self.test_path_arr:
-            if imagename.find('.png') != -1:
-                self.test_path_arr.append(os.path.join(test_path, imagename))
-        self.test_path_arr.sort()
-        if len(self.test_path_arr) > 0:
-            self.test_path = self.test_path_arr[0]
-        self.test_path_arr.append(self.test_path)
-        self.mode = 'Hash'
-
     def setup_image(self, blend_path, good_path, test_path):
         '''Used for setting up the case for the purpose of a image comparison test
            blend_path: the  path to the blend file for the case
@@ -295,17 +220,6 @@
                 self.good_path = self.good_path_arr[0]
             self.test_path = test_path
             
-    def generate_hash_animation(self, animation):
-        '''Designed mainly for internal use, but can be used for external purposes if needed
-           Generates a hash out of a given animation
-           animation: The animation that the hash will be made from
-           returns: The calculated hash'''
-        hash = 0
-        for image in animation:
-            frame_hash = self.generate_hash(image)
-            hash+=frame_hash
-        return hash
-
     def get_image_frame(self, frame_num):
         '''Gets a good image, and a test image (which assumes it's rendered) from the animation, based on their
            paths, and the given frame number.  Then creates a diff image out of the two other animations.  If the animations
@@ -330,10 +244,10 @@
            
         # Render depending on the verbosity needed
         if verbose:
-            command = blender_bin + ' -b ' + self.blend_path + " -o " + os.path.join(self.test_path,string.replace(self.name,'.blend','_####')) + ' -F PNG -x 1 -a'
+            command = blender_bin + ' -b ' + self.blend_path + " -o " + os.path.join(self.test_path,string.replace(self.name,'.blend','_####')) + ' -F PNG -x 1 -a -j 15'
             os.system(command)
         else:
-            p = Popen([blender_bin, '-b', self.blend_path, '-o', os.path.join(self.test_path,string.replace(self.name,'.blend','_####')), '-F', 'PNG', '-x', '1', '-a'], stdout=None, stderr=None, stdin=None)
+            p = Popen([blender_bin, '-b', self.blend_path, '-o', os.path.join(self.test_path,string.replace(self.name,'.blend','_####')), '-F', 'PNG', '-x', '1', '-a', '-j', '15'], stdout=None, stderr=None, stdin=None)
             p.wait()
             
         # Modify self.test_path for later use
@@ -406,47 +320,6 @@
             self.passed = False
         finally:
             return self.passed
-                        
-    def hash_test(self):
-        '''Performs the hash test on the animation in case that the testcase is being used as a hashtest.
-           If the setup_image method was used rather than the setup_hash method, the test attempts to generate
-           a hash based on that animation.  It assumes that the test animation has been rendered
-           The status of the test passing can be found in the passed field.
-           returns:  Whether or not the test passed'''
-           
-        ### TODO, bad code, to be updated ###
-        if test_image == None:
-            try:
-                for imagename in self.test_path_arr:
-                    im = Image.open(imagename)
-                    test_animation.append(im)
-                if len(test_animation) > 0:
-                    test_image = test_animation[0]
-            except IOError:
-                self.passed = False
-                self.good_hash = -1
-                self.test_hash = -1
-                self.diff_hash = -1
-                
-        if test_image != None:
-            if self.good_hash == None:
-                if good_image != None:
-                    self.good_hash = self.generate_hash_anim(good_animation)
-                else:
-                    self.passed = False
-                    self.message = 'No Good Hash or Good Image provided'
-                    return
-            if self.test_hash == None:
-                self.generate_hash_anim(test_animation)
-            if self.pixel_count == None:
-                self.pixel_count = 0
-                for image in test_animation:
-                    self.pixel_count+=image.size[0] * image.size[1]
-            self.diff_hash = abs(self.test_hash - self.good_hash)
-            if self.diff_hash < self.pixel_count/10:
-                self.passed = True
-            else:
-                self.passed = False
 
     def save_diff(self, output_path):
         '''Performs the hash test on the image in case that the testcase is being used as a hashtest.
@@ -509,55 +382,7 @@
             cases.append(test_case)
     return cases
 
-def get_hash_cases(blend_file_folder, hash_file, output_folder):
-    '''Returns the intersection of all of the hash cases listed in the hash_file, 
-       and image/animation cases in the given folder
-       blend_file_folder:  The path to the blend file
-       good_folder: The path to the good_image
-       output_folder: The path to where the output case is too be rendered
-       returns: An array of all of the generated cases'''
-        
-    # Setup variables
-    cases = []
-    image_cases = []
-    animation_cases = []
-    
-    # Run through the hash file, set up image_cases and animation_cases
-    file = open(hash_file, 'r')
-    for line in file:
-        (case_type, blend_file, hashcode) = line.split()
-        if case_type == 'Image:':
-            image_cases.append((blend_file, hashcode))
-        if case_type == 'Animation:':
-            animation_cases.append((blend_file, hashcode))
-            
-    # Run through the given folder:
-    # 1.  Initialize the intersection of image_cases and animation_cases, and the files found in the folder
-    # 2.  Append them to Cases
-    # 3.  Return the cases
-    for filename in os.listdir(blend_file_folder):
-        if filename.find('.blend') != -1:

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list