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

Leif Andersen leif.a.andersen at gmail.com
Fri Jul 9 23:05:17 CEST 2010


Revision: 30161
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30161
Author:   leifandersen
Date:     2010-07-09 23:05:17 +0200 (Fri, 09 Jul 2010)

Log Message:
-----------
1.  I've modified the code so that it should be able to work without a known good image, it will compare hashcodes.  However, currently while the class accepts a hashcode as a parameter, the global code does not use this at the moment.

2.  Got the hashcodes for every file in the render or animation folder of the current regression tests, saved in hashcodes.txt.

3.  I've fixed some constructor code.  Apperently class fields in python will point to the same thing (even if it's a new object), unless told otherwise.  (Or at least that's what my experiments tell me).

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

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/render/hashcodes.txt

Added: branches/soc-2010-leifandersen/tests/render/hashcodes.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/render/hashcodes.txt	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/render/hashcodes.txt	2010-07-09 21:05:17 UTC (rev 30161)
@@ -0,0 +1,54 @@
+CtrlObject.blend = -1
+Raptor_radio_ray_env.blend = 33982623
+allselect.blend = 13357554
+arealight.blend = 12065140
+array3.blend = 143049984
+bowl.blend = 6283770
+camera.blend = 1579067
+compo_idmask_cubes.blend = 29988479
+compo_map_uv.blend = 38220279
+compo_map_uv_cubes.blend = 29678781
+compo_map_zcombine_cubes.blend = 36673579
+composite_image.blend = 218981041
+composite_layers.blend = 26746916
+controller2.blend = 3687663
+cubesphere.blend = 3481153
+displace.blend = 15286177
+dolphin.blend = 47212314
+driven_hand.blend = 9502911
+driver-object-eyes.blend = 125922590
+dupliverts.blend = 6111411
+flaretest.blend = 90616561
+glass.blend = 25052476
+hairguide.blend = 12361972
+halostep.blend = 18936191
+knight.blend = 29232841
+lostride.blend = 18995802
+luxo.blend = 1283166
+mancandy_actiondeform.blend = 58838400
+mancandy_matching.blend = 39225600
+mirror_texture.blend = 18745929
+monkey_cornelius.blend = 31411894
+monkey_cornelius_bake.blend = 31288006
+monkey_cornelius_compo.blend = 31525697
+monkey_cornelius_light-passes.blend = 36589238
+monkey_cornelius_passes.blend = 29445852
+monkey_cornelius_shadbuf.blend = 113297051
+motionblender.blend = 2140986
+motor9.blend = 22404981
+only_shadow_lamp.blend = 15217479
+only_shadow_material.blend = 528474
+pathJumper.blend = 0
+refract_monkey.blend = 53649320
+relative.blend = 1758561
+robo_ao.blend = 29737827
+sequence.blend = 0
+softbody_basics.blend = -1
+softbody_curve_lattice.blend = 19242895
+sss.blend = 80845952
+stride_bone.blend = -1
+teapot_envmap.blend = 68155147
+teapot_soft.blend = 16755754
+vectorblur.blend = 51362950
+windows_tra_shadow.blend = 13032008
+

Modified: branches/soc-2010-leifandersen/tests/render/run.py
===================================================================
--- branches/soc-2010-leifandersen/tests/render/run.py	2010-07-09 20:38:42 UTC (rev 30160)
+++ branches/soc-2010-leifandersen/tests/render/run.py	2010-07-09 21:05:17 UTC (rev 30161)
@@ -25,12 +25,12 @@
     3. Setup Tests
     4. Save Diff'''
 
-    name = None
+    name = ''
     passed = None
-    good_path = None
-    blend_path = None
-    test_path = None
-    diff_path = None
+    good_path = ''
+    blend_path = ''
+    test_path = ''
+    diff_path = ''
     bad_pixels = None
     pixel_count = None
     diff_sum = None
@@ -39,10 +39,22 @@
     diff_image = None
     pixel_range = None
     difference = None
+    good_hash = None
+    test_hash = None
+    diff_hash = None
     message = ""
     ID = 'Image'
 
-    def __init__(self, blend_path, good_path, test_path):
+    def __init__(self):
+        self.name = 'Uninitialized'
+
+    def setup_hash(self, blend_path, good_hash, test_path):
+        self.name = os.path.split(blend_path)[1]
+        self.good_hash = good_hash
+        self.blend_path = blend_path
+        self.test_path = test_path
+
+    def setup_image(self, blend_path, good_path, test_path):
         '''Sets up a test case, with the blend_path, the known good path, and the test path
             For images, the known good path is a file, 
             for animations, it's a folder containing all of the frames'''
@@ -51,7 +63,16 @@
         self.blend_path = blend_path
         self.good_path = good_path
         self.test_path = test_path
+        self.good_hash = self.generate_hash(self.good_image)
 
+    def generate_hash(self, image):
+        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 format_frame(self, num):
         frame_num = str(num)
         while len(frame_num) < 4:
@@ -66,12 +87,13 @@
             command = BLENDER_BIN + ' -b ' + self.blend_path + ' -o ' + self.test_path + '_#### -F PNG -x 1 -f 1'
             os.system(command)
         else:
-            p = Popen([BLENDER_BIN, '-b', self.blend_path, '-o', self.test_path + '_####', '-F', 'PNG', '-x', '1', '-f', '1'], stdout=None, stderr=None, stdin=None)
+            p = Popen([BLENDER_BIN, '-b', self.blend_path, '-o', self.test_path + '_####', '-F', 'PNG', '-x', '1', '-f', '1'], stdout=PIPE, stderr=PIPE, stdin=PIPE)
             p.wait()
 
         self.test_path += '_0001.png'
         try:
             self.test_image = Image.open(self.test_path)
+            self.test_hash = self.generate_hash(self.test_image)
         except IOError:
             self.ID = 'Fail'
             self.test_image = None
@@ -85,9 +107,10 @@
 
     def setup_test(self):
         '''Runs the test, filling in all of the usefull fields'''
-        if self.test_image != None:
+        if self.good_image != None and self.test_image != None:
             self.diff_sum = 0
             self.diff_image = ImageChops.difference(self.good_image, self.test_image)
+            self.generate_hash(self.diff_image)
             self.bad_pixels = 0
             self.pixel_range = len(self.diff_image.histogram())
             self.pixel_count = self.diff_image.size[0] * self.diff_image.size[1]
@@ -103,6 +126,13 @@
             else:
                 self.passed = False
             return self.passed
+        elif self.good_hash != None and self.test_hash != None:
+            self.diff_hash = abs(self.good_hash - self.test_hash)
+            if self.diff_hash < 1000:
+                self.passed = True
+            else:
+                self.passed = False
+            return self.passed
 
     def save_diff(self, output_path):
         '''Saves the diff image to output_path'''
@@ -116,12 +146,12 @@
     name = None
     passed = None
     passed_arr = []
-    good_path = None
+    good_path = ''
     good_path_arr = []
-    blend_path = None
-    test_path = None
+    blend_path = ''
+    test_path = ''
     test_path_arr = []
-    diff_path = None
+    diff_path = ''
     diff_path_arr = []
     bad_pixels = None
     bad_pixels_arr = []
@@ -130,35 +160,88 @@
     diff_sum = None
     diff_sum_arr = []
     good_image = None
-    good_image_arr = []
+    good_animation = []
     test_image = None
-    test_image_arr = []
+    test_animation = []
     diff_image = None
-    diff_image_arr = []
+    diff_animation = []
     pixel_range = None
     pixel_range_arr = []
     difference = None
     diffference_arr = []
+    good_hash = None
+    good_hash_arr = []
+    test_hash = None
+    test_hash_arr = []
+    diff_hash = None
+    diff_hash_arr = []
     message = ""
     ID = 'Animation'
 
-    def __init__(self, blend_path, good_path, test_path):
+    def __init__(self):
+        self.name = 'Uninitialized'
+        self.passed_arr = []
+        self.good_path = ''
+        self.good_path_arr = []
+        self.blend_path = ''
+        self.test_path = ''
+        self.test_path_arr = []
+        self.diff_path = ''
+        self.diff_path_arr = []
+        self.bad_pixels_arr = []
+        self.pixel_count_arr = []
+        self.diff_sum_arr = []
+        self.good_animation = []
+        self.test_animation = []
+        self.diff_animation = []
+        self.pixel_range_arr = []
+        self.diffference_arr = []
+        self.good_hash_arr = []
+        self.test_hash_arr = []
+        self.diff_hash_arr = []
+
+    def setup_hash(self, blend_path, good_hash, test_path):
         ''''''
         self.name = os.path.split(blend_path)[1]
+        self.good_hash = good_hash
+        self.blend_path = blend_path
+        self.test_path = os.path.join(test_path, string.replace(self.name, '.blend', '_0001.png'))
+        self.test_path_arr.append(self.test_path)
+
+    def setup_image(self, blend_path, good_path, test_path):
+        ''''''
+        self.name = os.path.split(blend_path)[1]
         i=1
         for imagename in os.listdir(good_path):
             if imagename.find('.png') != -1:
                 self.good_path_arr.append(os.path.join(good_path, imagename))
                 im = Image.open(self.good_path_arr[i-1])
-                self.good_image_arr.append(im)
+                self.good_animation.append(im)
                 self.test_path_arr.append(os.path.join(test_path, string.replace(self.name, '.blend', '_' + self.format_frame(i) + '.png')))
+                # self.good_hash_arr.append(self.generate_hash_image(im)) TODO removed due to time contstraint
                 i+=1
 
         self.blend_path = blend_path
         self.good_path = self.good_path_arr[0]
-        self.good_image = self.good_image_arr[0]
+        self.good_image = self.good_animation[0]
         self.test_path = self.test_path_arr[0]
+#        self.good_hash = self.generate_hash(self.good_animation)
 
+    def generate_hash(self, animation):
+        hash = 0
+        for image in animation:
+            frame_hash = self.generate_hash_image(image)
+            hash+=frame_hash
+        return hash
+
+    def generate_hash_image(self, image):
+        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 format_frame(self, num):
         frame_num = str(num)
         while len(frame_num) < 4:
@@ -177,8 +260,10 @@
         try:
             for imagename in self.test_path_arr:
                 im = Image.open(imagename)
-                self.test_image_arr.append(im)
-            self.test_image = self.test_image_arr[0]
+                self.test_animation.append(im)
+                # self.test_hash_arr.append(self.generate_hash_image(im)) TODO, removed due to time constraint
+            self.test_image = self.test_animation[0]
+            self.test_hash = self.generate_hash(self.test_animation)
         except IOError:
             self.test_image = None
             self.passed = False
@@ -188,16 +273,22 @@
             self.diff_sum = 0
             self.difference = 0
             self.message = "Failed to render"
+            self.test_hash = -1
 
     def setup_test(self):
         ''''''
         if self.test_image != None:
 
-            for diff_image in self.good_image_arr:

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list