def test_render_cube_no_lighting(self): # test object part1 = CuboidPrimitive([0.0, 0.0, 0.0], [1.0, 1.0, 1.0]) s = Shape(forward_model=None, parts=[part1]) r = self.fwm_no_lighting.render(s) correct = np.load('test_images/cube_no_lighting.npy') self.assertAlmostEqual(np.sum(np.abs(r - correct)), 0.0) # test changing viewpoint for i, pos in enumerate(self.camera_pos): s.viewpoint = [pos] r = self.fwm_no_lighting.render(s) self.assertAlmostEqual(np.sum(np.abs(r - correct[i])), 0.0)
def test_render_cube_custom_lighting(self): # test object part1 = CuboidPrimitive([0.0, 0.0, 0.0], [1.0, 1.0, 1.0]) s = Shape(forward_model=None, parts=[part1]) r = self.fwm_custom_lighting.render(s) correct = np.load('test_images/cube_custom_lighting.npy') self.assertAlmostEqual(np.sum(np.abs(r - correct)), 0.0) # maximum intensity value for custom lighting should be around 174-175. This value is used in our likelihood # calculations; therefore, it is important to make sure that it does not change. self.assertTrue(175.0 > np.max(r) > 174.0) # test changing viewpoint for i, pos in enumerate(self.camera_pos): s.viewpoint = [pos] r = self.fwm_custom_lighting.render(s) self.assertAlmostEqual(np.sum(np.abs(r - correct[i])), 0.0)