def main(): global window, ts, width, height (width, height) = (1024, 1024) glutInit(sys.argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH) glutInitWindowSize(width, height) glutInitWindowPosition(0, 0) window = glutCreateWindow("Stereo Volume Rendering") glutDisplayFunc(display) glutIdleFunc(idle) glutReshapeFunc(resize) glutMouseFunc(mouseButton) glutMotionFunc(mouseMotion) glutKeyboardFunc(keyPressed) init_gl(width, height) # create texture for blitting to screen create_texture(width, height) import pycuda.gl.autoinit import pycuda.gl cuda_gl = pycuda.gl create_PBO(width, height) # ----- Load and Set Volume Data ----- density_grid = np.load("/home/bogert/dd150_log_densities.npy") mi, ma = 21.5, 24.5 bins = 5000 tf = ColorTransferFunction((mi, ma), bins) tf.map_to_colormap(mi, ma, colormap="algae", scale_func=scale_func) ts = TheiaScene(volume=density_grid, raycaster=FrontToBackRaycaster(size=(width, height), tf=tf)) ts.get_raycaster().set_sample_size(0.01) ts.get_raycaster().set_max_samples(5000) ts.update() glutMainLoop()
def main(): global window, ts, width, height (width, height) = (1024, 1024) glutInit(sys.argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH ) glutInitWindowSize(width, height) glutInitWindowPosition(0, 0) window = glutCreateWindow("Stereo Volume Rendering") glutDisplayFunc(display) glutIdleFunc(idle) glutReshapeFunc(resize) glutMouseFunc( mouseButton ) glutMotionFunc( mouseMotion ) glutKeyboardFunc(keyPressed) init_gl(width, height) # create texture for blitting to screen create_texture(width, height) import pycuda.gl.autoinit import pycuda.gl cuda_gl = pycuda.gl create_PBO(width, height) # ----- Load and Set Volume Data ----- density_grid = np.load("/home/bogert/dd150_log_densities.npy") mi, ma= 21.5, 24.5 bins = 5000 tf = ColorTransferFunction( (mi, ma), bins) tf.map_to_colormap(mi, ma, colormap="algae", scale_func = scale_func) ts = TheiaScene(volume = density_grid, raycaster = FrontToBackRaycaster(size = (width, height), tf = tf)) ts.get_raycaster().set_sample_size(0.01) ts.get_raycaster().set_max_samples(5000) ts.update() glutMainLoop()
'-preset', 'ultrafast', '-qp', '0', '-pix_fmt', 'yuv420p', #Name of the output 'bolshoiplanck2.mkv' ], stdin=sp.PIPE, stdout=sp.PIPE) #Now we loop and produce 500 frames for k in range(0, 500): #update the scene resulting in a new image ts.update() #get the image array from the ray caster array = ts.source.get_results() #send the image array to ffmpeg array.tofile(pipe.stdin) #rotate the scene by 0.01 rads in x,y & z ts.camera.rotateX(0.01) ts.camera.rotateZ(0.01) ts.camera.rotateY(0.01) #zoom in 0.01% for a total of a 5% zoom ts.camera.zoom(0.01)
'-i', '-', # Tells FFMPEG not to expect any audio '-an', #Setup video encoder #Use any encoder you life available from ffmpeg '-vcodec', 'libx264', '-preset', 'ultrafast', '-qp', '0', '-pix_fmt', 'yuv420p', #Name of the output 'bolshoiplanck2.mkv' ], stdin=sp.PIPE,stdout=sp.PIPE) #Now we loop and produce 500 frames for k in range (0,500) : #update the scene resulting in a new image ts.update() #get the image array from the ray caster array = ts.source.get_results() #send the image array to ffmpeg array.tofile(pipe.stdin) #rotate the scene by 0.01 rads in x,y & z ts.camera.rotateX(0.01) ts.camera.rotateZ(0.01) ts.camera.rotateY(0.01) #zoom in 0.01% for a total of a 5% zoom ts.camera.zoom(0.01)