def render(self, path_to_frame):
"""This renders the frame at path_to_frame
It will time only the rendering (no I/O), log the time, and write the
output image to disk.
"""
input_img = util.read_img(path_to_frame)
output_img = np.zeros(input_img.shape)
# load module
sys.path.append("../../apps/blur_one_stage")
import blur_one_stage
sys.path.remove("../../apps/blur_one_stage")
# this is equivalent to using the @jit function decorator:
jitted_func = numba.jit(blur_one_stage.gaussian_blur)
t1 = time.time()
jitted_func(input_img, output_img)
t2 = time.time()
print("Elapsed time: %f" % (t2 - t1))
output_filename = path_to_frame.split(os.sep)[-1]
util.write_img(output_img,
os.path.join(self.output_directory, output_filename))
# append timing data to log file:
with open(self.log_filename, "a") as f:
f.write("%s, %f, %f\n" % (
os.path.join(self.output_directory, output_filename),
t2 - t1,
1./(t2 - t1)))
评论列表
文章目录