How to use the mayavi.mlab.clf function in mayavi

To help you get started, we’ve selected a few mayavi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enthought / mayavi / integrationtests / mayavi / test_mlab.py View on Github external
def run_mlab_examples():
    from mayavi import mlab
    from mayavi.tools.animator import Animator

    ############################################################
    # run all the "test_foobar" functions in the mlab module.
    for name, func in getmembers(mlab):
        if not callable(func) or not name[:4] in ('test', 'Test'):
            continue

        if sys.platform == 'win32' and name == 'test_mesh_mask_custom_colors':
            # fixme: This test does not seem to work on win32, disabling for now.
            continue

        mlab.clf()
        GUI.process_events()
        obj = func()

        if isinstance(obj, Animator):
            obj.delay = 10
            # Close the animation window.
            obj.close()
            while is_timer_running(obj.timer):
                GUI.process_events()
                sleep(0.05)

        # Mayavi has become too fast: the operator cannot see if the
        # Test function was succesful.
        GUI.process_events()
        sleep(0.1)
github colincsl / pyKinectTools / pyKinectTools / scripts / ExtractAndVisualizeVideo.py View on Github external
coms_np = np.array(coms)
								xs = np.minimum(np.maximum(mapRez[0]+((coms_np[:,2]+500)/3000.*mapRez[0]).astype(np.int), 0),mapRez[0]-1)
								ys = np.minimum(np.maximum(((coms_np[:,0]+500)/1500.*mapRez[0]).astype(np.int), 0), mapRez[1]-1)
								mapIm[xs, ys] = 255
								vv.imshow("Map", mapIm)
								# scatter(coms_np[:,0], -coms_np[:,2])


							'''3D Vis'''
							if 0:
								# figure = mlab.figure(1, fgcolor=(1,1,1), bgcolor=(0,0,0))
								# from pyKinectTools.utils.DepthUtils import *
								pts = depthIm2XYZ(depthIm).astype(np.int)
								interval = 25
								figure.scene.disable_render = True
								mlab.clf()
								# ss = mlab.points3d(-pts[::interval,0], pts[::interval,1], pts[::interval,2], colormap='Blues', vmin=1000., vmax=5000., mode='2dvertex')
								ss = mlab.points3d(pts[::interval,0], pts[::interval,1], pts[::interval,2], 5.-(np.minimum(pts[::interval,2], 5000)/float((-pts[:,2]).max()))/1000., scale_factor=25., colormap='Blues')#, mode='2dvertex')
								# , scale_factor=25.
								mlab.view(azimuth=0, elevation=0, distance=3000., focalpoint=(0,0,0), figure=figure)#, reset_roll=False)
								# mlab.roll(90)
								currentView = mlab.view()
								figure.scene.disable_render = False
								mlab.draw()
								# mlab.show()
								# ss = mlab.points3d(pts[::interval,0], pts[::interval,1], pts[::interval,2], color=col, scale_factor=5)
								# ss = mlab.points3d(pts[:,0], pts[:,1], pts[:,2], color=(1,1,1), scale_factor=5)

								# ss = mlab.points3d(pts[:,0], pts[:,1], pts[:,2])


						''' Playback control: Look at keyboard input '''
github enthought / mayavi / docs / source / render_images.py View on Github external
def capture_image(func, filename):
    """ Runs a function doing some mayavi drawing and save the resulting
        scene to a file.
    """
    mlab.clf()
    func()
    if not filename[-4:] in ('.jpg', '.png'):
        filename = '%s.jpg' % filename
    mlab.savefig(filename , size=(400, 400) )
    os.system('convert %s -trim %s' % (filename, filename))
github lambdaloop / anipose / anipose / label_videos_3d.py View on Github external
points = np.copy(all_points[:, 20])
    points[0] = low
    points[1] = high

    s = np.arange(points.shape[0])
    good = ~np.isnan(points[:, 0])

    fig = mlab.figure(bgcolor=(1,1,1), size=(500,500))
    fig.scene.anti_aliasing_frames = 2

    low, high = np.percentile(points[good, 0], [10,90])
    scale_factor = (high - low) / 10.0

    mlab.clf()
    pts = mlab.points3d(points[:, 0], -points[:, 1], points[:, 2], s,
                        scale_mode='none', scale_factor=scale_factor)
    lines = connect_all(points, scheme, bp_dict, cmap)
    mlab.orientation_axes()

    view = list(mlab.view())

    mlab.view(focalpoint='auto', distance='auto')

    for framenum in trange(data.shape[0], ncols=70):
        fig.scene.disable_render = True

        if framenum in framedict:
            points = all_points[:, framenum]
        else:
            points = np.ones((nparts, 3))*np.nan
github jeffmahler / GPIS / src / grasp_selection / mab_single_object_objective.py View on Github external
T_world_camera = T_camera_world.inverse()
    
            R_stp_obj = self.stable_pose.r
            T_obj_stp = stf.SimilarityTransform3D(pose=tfx.pose(R_stp_obj.T, np.zeros(3)), from_frame='stp', to_frame='obj')
            
            t_stp_table = np.array([0, 0, z])
            T_stp_table = stf.SimilarityTransform3D(pose=tfx.pose(np.eye(3), t_stp_table), from_frame='table', to_frame='stp')
    
            T_obj_world = T_obj_camera.dot(T_camera_world)
            
            T_gripper_obj = grasp.gripper_transform(gripper=self.gripper)
            T_gripper_world = T_gripper_obj.dot(T_obj_world)

            # visualize the robot's understanding of the world
            logging.info('Displaying robot world state')
            mv.clf()
            mvis.MayaviVisualizer.plot_table(T_table_world, d=table_extent)
            mvis.MayaviVisualizer.plot_pose(T_world, alpha=alpha, tube_radius=tube_radius, center_scale=center_scale)
            mvis.MayaviVisualizer.plot_pose(T_obj_world, alpha=alpha, tube_radius=tube_radius, center_scale=center_scale)
            mvis.MayaviVisualizer.plot_pose(T_camera_world, alpha=alpha, tube_radius=tube_radius, center_scale=center_scale)
            mvis.MayaviVisualizer.plot_mesh(object_mesh, T_obj_world, color=(1,0,0))
            mvis.MayaviVisualizer.plot_point_cloud(cb_points_camera, T_world_camera, color=(1,1,0))
            mvis.MayaviVisualizer.plot_gripper(grasp, T_obj_world, self.gripper)

            delta_view = 360.0 / num_grasp_views
            mv.view(distance=cam_dist)
            for j in range(num_grasp_views):
                az = j * delta_view
                mv.view(azimuth=az)
                figname = 'estimated_scene_view_%d.png' %(j)                
                mv.savefig(os.path.join(logging_dir, figname))
github JohnKendrick / PDielec / PDielec / ViewerClass.py View on Github external
def draw(self):
        mlab.clf()
        self.draw_noupdate()
        self.drawDisplacements()
github enthought / mayavi / examples / mayavi / mlab / chemistry.py View on Github external
try:
        from urllib import urlopen
    except ImportError:
        from urllib.request import urlopen
    print('Downloading data, please wait')
    opener = urlopen(
        'http://code.enthought.com/projects/mayavi/data/h2o-elf.cube'
        )
    open('h2o-elf.cube', 'wb').write(opener.read())


# Plot the atoms and the bonds ################################################
import numpy as np
from mayavi import mlab
mlab.figure(1, bgcolor=(0, 0, 0), size=(350, 350))
mlab.clf()

# The position of the atoms
atoms_x = np.array([2.9, 2.9, 3.8]) * 40 / 5.5
atoms_y = np.array([3.0, 3.0, 3.0]) * 40 / 5.5
atoms_z = np.array([3.8, 2.9, 2.7]) * 40 / 5.5

O = mlab.points3d(atoms_x[1:-1], atoms_y[1:-1], atoms_z[1:-1],
                  scale_factor=3,
                  resolution=20,
                  color=(1, 0, 0),
                  scale_mode='none')

H1 = mlab.points3d(atoms_x[:1], atoms_y[:1], atoms_z[:1],
                   scale_factor=2,
                   resolution=20,
                   color=(1, 1, 1),
github rohitgirdhar / GenerativePredictableVoxels / src / voxelize / transformAndVisVoxels.py View on Github external
def saveVisSnapshotMayavi(data, outfpath=None, fig=None):
  import mayavi.mlab
  figWasNone = 0
  if fig is None:
    mayavi.mlab.options.offscreen = True
    fig = mayavi.mlab.figure(bgcolor=(1,1,1))
    figWasNone = 1
  else:
    mayavi.mlab.clf(fig)
  visualizeDenseMayavi(data, fig)
  mayavi.mlab.view(113.21283385785944,142.9695294105835,roll=93.37654235007402)
  I = mayavi.mlab.screenshot(fig)
  if figWasNone:
    mayavi.mlab.close(fig)
  if outfpath is not None:
    scipy.misc.imsave(outfpath, I)
  return I
github amaggi / waveloc / PyProgs / double_diff.py View on Github external
from CZ_color import CZ_W_2_color

    # Stations coordinates
    xsta, ysta, zsta = [], [], []
    for sta in sorted(stations):
        xsta.append(stations[sta]['x'])
        ysta.append(stations[sta]['y'])
        zsta.append(stations[sta]['elev'])

    z_ph = [-elt for elt in z]

    # Initial hypocentral parameters
    xini, yini, zini, zini_ph, to_ini = coord_cluster(cluster[i], locs)

    mlab.figure(i, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0), size=(1000, 900))
    mlab.clf()
    # yellow : initial locations
    mlab.points3d(xini, yini, zini_ph, color=(1, 1, 0), scale_factor=0.2)
    mlab.points3d(xsta, ysta, zsta, color=(1, 0, 0), scale_factor=0.05,
                  mode='cube')
    # cyan : new locations
    mlab.points3d(x, y, z_ph, color=(0, 1, 1), scale_factor=0.2)
    mlab.axes(extent=area, color=(0, 0, 0))  # axe des z positif vers le haut
    mlab.outline(extent=area, color=(0, 0, 0))
    mlab.title("cluster=%s,  threshold=%s,  nbmin=%s" % (i, threshold, nbmin),
               height=0.1, size=0.35, color=(0, 0, 0))

    if len(cluster[i]) < 20:
        for ind_I in range(len(cluster[i])):
            for ind_J in range(ind_I+1, len(cluster[i])):
                ev_I = cluster[i][ind_I]-1
                ev_J = cluster[i][ind_J]-1