当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkCamera方法代码示例

本文整理汇总了Python中vtk.vtkCamera方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkCamera方法的具体用法?Python vtk.vtkCamera怎么用?Python vtk.vtkCamera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vtk的用法示例。


在下文中一共展示了vtk.vtkCamera方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def __init__(self):
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(0.5, 0.5, 0.5)
        self.renderer.ResetCamera()

        axes_actor = vtk.vtkAxesActor()
        axes_actor.AxisLabelsOff()
        self.renderer.AddActor(axes_actor)

        self.window = vtk.vtkRenderWindow()
        self.window.AddRenderer(self.renderer)

        self.interactor = vtk.vtkRenderWindowInteractor()
        self.interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        self.interactor.SetRenderWindow(self.window)

        self.camera = vtk.vtkCamera()
        self.camera.SetViewUp(0.0, -1.0, 0.0)
        self.camera.SetPosition(0.0, 0.0, -5)
        self.camera.SetFocalPoint(0.0, 0.0, 0.0)
        # self.camera.SetClippingRange(0.0, 100000)

        self.renderer.SetActiveCamera(self.camera) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:25,代码来源:vtkVisualization.py

示例2: scale_point

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def scale_point(camera, point, invert=False):
    """Scale a point using the camera's transform matrix.

    Parameters
    ----------
    camera : vtk.vtkCamera
        The camera who's matrix to use.

    point : tuple(float)
        Length 3 tuple of the point coordinates.

    invert : bool
        If True, invert the matrix to transform the point out of the
        camera's transformed space. Default is False to transform a
        point from world coordinates to the camera's transformed space.

    """
    if invert:
        mtx = vtk.vtkMatrix4x4()
        mtx.DeepCopy(camera.GetModelTransformMatrix())
        mtx.Invert()
    else:
        mtx = camera.GetModelTransformMatrix()
    scaled = mtx.MultiplyDoublePoint((point[0], point[1], point[2], 0.0))
    return (scaled[0], scaled[1], scaled[2]) 
开发者ID:pyvista,项目名称:pyvista,代码行数:27,代码来源:renderer.py

示例3: unlink_views

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def unlink_views(self, views=None):
        """Unlink the views' cameras.

        Parameters
        ----------
        views : None | int | tuple or list
            If ``views`` is None unlink all the views, if ``views``
            is int unlink the selected view's camera or if ``views``
            is a tuple or a list, unlink the given views cameras.

        """
        if views is None:
            for renderer in self.renderers:
                renderer.camera = vtk.vtkCamera()
                renderer.reset_camera()
        elif isinstance(views, int):
            self.renderers[views].camera = vtk.vtkCamera()
            self.renderers[views].reset_camera()
        elif isinstance(views, collections.abc.Iterable):
            for view_index in views:
                self.renderers[view_index].camera = vtk.vtkCamera()
                self.renderers[view_index].reset_camera()
        else:
            raise TypeError('Expected type is None, int, list or tuple:'
                            '{} is given'.format(type(views))) 
开发者ID:pyvista,项目名称:pyvista,代码行数:27,代码来源:plotting.py

示例4: set_camera

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def set_camera(scene, camera):
    """
        Sets the position of the camera of a brainrender scene.

        :param scene: instance of Scene()
        :param camera: either a string with the name of one of the available cameras, or
                        a dictionary of camera parameters. 
        
    """
    if camera is None: return

    if not isinstance(camera, vtk.vtkCamera):
        # Get camera params
        camera = check_camera_param(camera)

        # set params
        set_camera_params(scene.plotter.camera, camera)
    else:
        scene.plotter.camera = camera
    return camera 
开发者ID:BrancoLab,项目名称:BrainRender,代码行数:22,代码来源:camera.py

示例5: unlink_camera

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def unlink_camera(self):
        """
        Create a fresh vtkCamera instance and set it to the renderer
        """
        import vtk
        old_camera = self.vtk_camera
        new_camera = vtk.vtkCamera()
        self.vtk_camera = new_camera
        if self.camera is not None:
            for k, v in self.camera.items():
                if type(v) is list:
                    getattr(new_camera, 'Set' + k[0].capitalize() + k[1:])(*v)
                else:
                    getattr(new_camera, 'Set' + k[0].capitalize() + k[1:])(v)
        else:
            new_camera.DeepCopy(old_camera) 
开发者ID:holoviz,项目名称:panel,代码行数:18,代码来源:vtk.py

示例6: buildcam

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def buildcam(cm):
    """
        Builds a camera from a dictionary of parameters, from vtkplotter
    """

    cm = cm.copy()
    
    cm_pos = cm.pop("position", None)
    cm_focalPoint = cm.pop("focal", None)
    cm_viewup = cm.pop("viewup", None)
    cm_distance = cm.pop("distance", None)
    cm_clippingRange = cm.pop("clipping", None)
    cm_parallelScale = cm.pop("parallelScale", None)
    cm_thickness = cm.pop("thickness", None)
    cm_viewAngle = cm.pop("viewAngle", None)

    cm = vtk.vtkCamera()

    if cm_pos is not None: cm.SetPosition(cm_pos)
    if cm_focalPoint is not None: cm.SetFocalPoint(cm_focalPoint)
    if cm_viewup is not None: cm.SetViewUp(cm_viewup)
    if cm_distance is not None: cm.SetDistance(cm_distance)
    if cm_clippingRange is not None: cm.SetClippingRange(cm_clippingRange)
    if cm_parallelScale is not None: cm.SetParallelScale(cm_parallelScale)
    if cm_thickness is not None: cm.SetThickness(cm_thickness)
    if cm_viewAngle is not None: cm.SetViewAngle(cm_viewAngle)
    
    return cm 
开发者ID:BrancoLab,项目名称:BrainRender,代码行数:30,代码来源:camera.py

示例7: visualize_prediction

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def visualize_prediction(pointcloud, colors, poses=None, renwin=None):
    """ render point cloud and cameras """

    renderer = vtk.vtkRenderer()
    renderer.SetBackground(0, 0, 0)

    pointcloud_actor = create_pointcloud_actor(points=pointcloud, colors=colors)
    pointcloud_actor.GetProperty().SetPointSize(2)
    renderer.AddActor(pointcloud_actor)

    for pose in poses:
        R, t = pose[:3, :3], pose[:3, 3]
        cam_actor = create_camera_actor(R,t)
        cam_actor.GetProperty().SetColor((255, 255, 0))
        renderer.AddActor(cam_actor)

    camera = vtk.vtkCamera()
    camera.SetPosition((1, -1, -2));
    camera.SetViewUp((0, -1, 0));
    camera.SetFocalPoint((0, 0, 2));

    renderer.SetActiveCamera(camera)
    renwin = vtk.vtkRenderWindow()

    renwin.SetWindowName("Point Cloud Viewer")
    renwin.SetSize(800,600)
    renwin.AddRenderer(renderer)
 
    # An interactor
    interactor = vtk.vtkRenderWindowInteractor()
    interstyle = vtk.vtkInteractorStyleTrackballCamera()
    interactor.SetInteractorStyle(interstyle)
    interactor.SetRenderWindow(renwin)

    # Render and interact
    renwin.Render()
    interactor.Initialize()
    interactor.Start() 
开发者ID:princeton-vl,项目名称:DeepV2D,代码行数:40,代码来源:vis.py

示例8: run

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def run(self):
        renderer = vtk.vtkRenderer()
        renderer.SetBackground(0, 0, 0)

        camera = vtk.vtkCamera()
        camera.SetPosition((1, -1, -2));
        camera.SetViewUp((0, -1, 0));
        camera.SetFocalPoint((0, 0, 2));
        renderer.SetActiveCamera(camera)

        renwin = vtk.vtkRenderWindow()
        renwin.SetWindowName("Point Cloud Viewer")
        renwin.SetSize(800,600)
        renwin.AddRenderer(renderer)

        interactor = vtk.vtkRenderWindowInteractor()
        interstyle = vtk.vtkInteractorStyleTrackballCamera()
        interactor.SetInteractorStyle(interstyle)
        interactor.SetRenderWindow(renwin)

        interactor.Initialize()

        cb = vtkTimerCallback(self.cinematic, self.render_path, self.clear_points)
        cb.queue = self.queue

        interactor.AddObserver('TimerEvent', cb.execute)
        timerId = interactor.CreateRepeatingTimer(100);

        #start the interaction and timer
        interactor.Start() 
开发者ID:princeton-vl,项目名称:DeepV2D,代码行数:32,代码来源:vis.py

示例9: getViewCameraCopy

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def getViewCameraCopy(self):
        camera = vtk.vtkCamera()
        camera.DeepCopy(self.view.camera())
        return camera 
开发者ID:RobotLocomotion,项目名称:director,代码行数:6,代码来源:cameracontrol.py

示例10: getCameraCopy

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def getCameraCopy(self):
        camera = vtk.vtkCamera()
        camera.DeepCopy(self.view.camera())
        return camera 
开发者ID:RobotLocomotion,项目名称:director,代码行数:6,代码来源:cameracontrol.py

示例11: create_render_window

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkCamera [as 别名]
def create_render_window(actors, callbacks, **kwargs):
    """ Creates VTK render window with an interactor.

    :param actors: list of VTK actors
    :type actors: list, tuple
    :param callbacks: callback functions for registering custom events
    :type callbacks: dict
    """
    # Get keyword arguments
    figure_size = kwargs.get('figure_size', (800, 600))
    camera_position = kwargs.get('camera_position', (0, 0, 100))

    # Find camera focal point
    center_points = []
    for actor in actors:
        center_points.append(actor.GetCenter())
    camera_focal_point = linalg.vector_mean(*center_points)

    # Create camera
    camera = vtk.vtkCamera()
    camera.SetPosition(*camera_position)
    camera.SetFocalPoint(*camera_focal_point)

    # Create renderer
    renderer = vtk.vtkRenderer()
    renderer.SetActiveCamera(camera)
    renderer.SetBackground(1.0, 1.0, 1.0)

    # Add actors to the scene
    for actor in actors:
        renderer.AddActor(actor)

    # Render window
    render_window = vtk.vtkRenderWindow()
    render_window.AddRenderer(renderer)
    render_window.SetSize(*figure_size)

    # Render window interactor
    window_interactor = vtk.vtkRenderWindowInteractor()
    window_interactor.SetRenderWindow(render_window)

    # Add event observers
    for cb in callbacks:
        window_interactor.AddObserver(cb, callbacks[cb][0], callbacks[cb][1])  # cb name, cb function ref, cb priority

    # Render actors
    render_window.Render()

    # Set window name after render() is called
    render_window.SetWindowName("geomdl")

    # Use trackball camera
    interactor_style = vtk.vtkInteractorStyleTrackballCamera()
    window_interactor.SetInteractorStyle(interactor_style)

    # Start interactor
    window_interactor.Start()

    # Return window interactor instance
    return window_interactor 
开发者ID:orbingol,项目名称:NURBS-Python,代码行数:62,代码来源:vtk_helpers.py


注:本文中的vtk.vtkCamera方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。