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


Python vtk.vtkUnsignedCharArray方法代码示例

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


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

示例1: test

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def test(self):
        """`ArraysToRGBA`: make sure no errors arise"""
        # create an input with three arrays that can be RGB
        r = np.random.randint(0, 255, 300)
        g = np.random.randint(0, 255, 300)
        b = np.random.randint(0, 255, 300)
        a = np.random.uniform(0, 1, 300)
        # now make it an arbirtray dataset
        df = pd.DataFrame(data=np.c_[r,g,b,r,g,b,a], columns=['x','y','z','R','G','B','A'])
        data = interface.points_to_poly_data(df)
        # Set up the algorithm
        colored = ArraysToRGBA().apply(data, 'R', 'G', 'B', 'A')
        # Make sure there is a new 'Colors' Array
        arr = colored.GetPointData().GetArray('Colors')
        self.assertTrue(isinstance(arr, vtk.vtkUnsignedCharArray))
        return True



############################################################################### 
开发者ID:OpenGeoVis,项目名称:PVGeo,代码行数:22,代码来源:filters_test.py

示例2: draw_one_grd_vtk

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def draw_one_grd_vtk(ls):  # arr:[a,b,c,d],a:orig, b, point1, c,point 2, d,color
    source = vtk.vtkPlaneSource()
    source.SetOrigin(ls[0])
    source.SetPoint1(ls[1])
    source.SetPoint2(ls[2])
    source.Update()
    # source.SetPoint1(0, 0, 0)
    # source.SetPoint2(4, 3, 0)

    # mapper
    mapper = vtk.vtkPolyDataMapper()
    color = vtk.vtkUnsignedCharArray()
    color.SetName("colors")
    color.SetNumberOfComponents(3)

    # color_tup = np.random.randint(1, 255, 3)

    color.SetNumberOfTuples(source.GetOutput().GetNumberOfCells())
    for i in xrange(source.GetOutput().GetNumberOfCells()):
        color_tup = np.array([255, 255, 255]) * ls[3]
        color.InsertTuple(i, color_tup)

    source.GetOutput().GetCellData().SetScalars(color)

    mapper.SetInputConnection(source.GetOutputPort())

    # actor
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    # assign actor to the renderer
    # ren.AddActor(actor)

    return actor


# generate the color list of the point cloud for different color styles. intens_rg: color by reflectance intensity (red:high green:low),
# intens: color by reflectance intensity (white:high back:low), autumn: matplotlib autumn color map,  cool: matplotlib cool color map 
开发者ID:mfxox,项目名称:ILCC,代码行数:40,代码来源:utility.py

示例3: vis_3D_points

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def vis_3D_points(full_lidar_arr, color_style="intens_rg"):
    all_rows = full_lidar_arr.shape[0]
    Colors = vtk.vtkUnsignedCharArray()
    Colors.SetNumberOfComponents(3)
    Colors.SetName("Colors")
    Points = vtk.vtkPoints()
    Vertices = vtk.vtkCellArray()

    tuple_ls = gen_color_tup_for_vis(color_style, xyzi_arr=full_lidar_arr)

    for k in xrange(all_rows):
        point = full_lidar_arr[k, :3]
        id = Points.InsertNextPoint(point[0], point[1], point[2])
        Vertices.InsertNextCell(1)
        Vertices.InsertCellPoint(id)

        rgb_tuple = tuple_ls[k]
        if vtk.VTK_MAJOR_VERSION >= 7:
            Colors.InsertNextTuple(rgb_tuple)
        else:
            Colors.InsertNextTupleValue(rgb_tuple)
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(Points)
    polydata.SetVerts(Vertices)
    polydata.GetPointData().SetScalars(Colors)
    polydata.Modified()

    mapper = vtk.vtkPolyDataMapper()
    if vtk.VTK_MAJOR_VERSION < 6:
        mapper.SetInput(polydata)
    else:
        mapper.SetInputData(polydata)
    mapper.SetColorModeToDefault()
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetPointSize(8)

    return actor


# visualize 3D points with specified color array 
开发者ID:mfxox,项目名称:ILCC,代码行数:43,代码来源:utility.py

示例4: vis_pcd_color_arr

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def vis_pcd_color_arr(array_data, color_arr=[46, 204, 113]):
    all_rows = array_data.shape[0]
    Colors = vtk.vtkUnsignedCharArray()
    Colors.SetNumberOfComponents(3)
    Colors.SetName("Colors")

    Points = vtk.vtkPoints()
    Vertices = vtk.vtkCellArray()

    for k in xrange(all_rows):
        point = array_data[k, :]
        id = Points.InsertNextPoint(point[0], point[1], point[2])
        Vertices.InsertNextCell(1)
        Vertices.InsertCellPoint(id)
        if vtk.VTK_MAJOR_VERSION >= 7:
            Colors.InsertNextTuple(color_arr)
        else:
            Colors.InsertNextTupleValue(color_arr)
    polydata = vtk.vtkPolyData()
    polydata.SetPoints(Points)
    polydata.SetVerts(Vertices)
    polydata.GetPointData().SetScalars(Colors)
    polydata.Modified()

    mapper = vtk.vtkPolyDataMapper()
    if vtk.VTK_MAJOR_VERSION <= 5:
        mapper.SetInput(polydata)
    else:
        mapper.SetInputData(polydata)
    mapper.SetColorModeToDefault()
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetPointSize(10)
    return actor


# visualize with actor: 
开发者ID:mfxox,项目名称:ILCC,代码行数:39,代码来源:utility.py

示例5: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def __init__(self, points: np.ndarray=None, colors: np.ndarray=None):
        assert (points is None and colors is None) or (points is not None and colors is not None)

        self.num_points = 0

        # VTK geometry representation
        self._points = vtk.vtkPoints()

        # VTK color representation
        self._colors = vtk.vtkUnsignedCharArray()
        self._colors.SetName("Colors")
        self._colors.SetNumberOfComponents(3)

        # Visualization pipeline
        # - Data source
        point_data = vtk.vtkPolyData()
        point_data.SetPoints(self._points)
        point_data.GetPointData().SetScalars(self._colors)

        # - Automatically generate topology cells from points
        mask_points = vtk.vtkMaskPoints()
        mask_points.SetInputData(point_data)
        mask_points.GenerateVerticesOn()
        mask_points.SingleVertexPerCellOn()
        mask_points.Update()

        # - Map the data representation to graphics primitives
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(mask_points.GetOutputPort())

        super().__init__(mapper)

        self.add_points(points, colors) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:35,代码来源:vtkVisualization.py

示例6: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e8):
        self.maxNumPoints = maxNumPoints
        self.vtkPolyData = vtk.vtkPolyData()
        self.clear_points()

        self.colors = vtk.vtkUnsignedCharArray()
        self.colors.SetNumberOfComponents(3)
        self.colors.SetName("Colors")

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputData(self.vtkPolyData)

        self.vtkActor = vtk.vtkActor()
        self.vtkActor.SetMapper(mapper)
        self.vtkActor.GetProperty().SetPointSize(2) 
开发者ID:VisualComputingInstitute,项目名称:vkitti3D-dataset,代码行数:17,代码来源:viz.py

示例7: create_actor

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def create_actor(self):
        self.points = vtk.vtkPoints()
        self.colors = vtk.vtkUnsignedCharArray()
        self.colors.SetName("colors")
        self.colors.SetNumberOfComponents(4)

        polydata = vtk.vtkPolyData()
        polydata.SetPoints(self.points)
        polydata.GetPointData().SetScalars(self.colors)

        # create cell
        voxel = self.create_voxel()

        self.glyph3D = vtk.vtkGlyph3D()
        self.glyph3D.SetColorModeToColorByScalar()
        self.glyph3D.SetSource(voxel.GetOutput())
        self.glyph3D.SetInput(polydata)
        self.glyph3D.ScalingOff()
        self.glyph3D.Update()

        # mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(self.glyph3D.GetOutput())

        # actor
        self.actor = vtk.vtkActor()
        self.actor.SetMapper(mapper)
        self.actor.GetProperty().SetAmbient(0.15) 
开发者ID:maxorange,项目名称:pix2vox,代码行数:30,代码来源:gui_viewer.py

示例8: create_pointcloud_polydata

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def create_pointcloud_polydata(points, colors=None):
    """Creates a vtkPolyData object with the point cloud from numpy arrays
    
    points: numpy.ndarray
        pointcloud with shape (n,3)
    
    colors: numpy.ndarray
        uint8 array with colors for each point. shape is (n,3)

    Returns vtkPolyData object
    """
    import vtk
    vpoints = vtk.vtkPoints()
    vpoints.SetNumberOfPoints(points.shape[0])
    for i in range(points.shape[0]):
        vpoints.SetPoint(i, points[i])
    vpoly = vtk.vtkPolyData()
    vpoly.SetPoints(vpoints)
    
    if not colors is None:
        vcolors = vtk.vtkUnsignedCharArray()
        vcolors.SetNumberOfComponents(3)
        vcolors.SetName("Colors")
        vcolors.SetNumberOfTuples(points.shape[0])
        for i in range(points.shape[0]):
            vcolors.SetTuple3(i ,colors[i,0],colors[i,1], colors[i,2])
        vpoly.GetPointData().SetScalars(vcolors)

    vcells = vtk.vtkCellArray()
    
    for i in range(points.shape[0]):
        vcells.InsertNextCell(1)
        vcells.InsertCellPoint(i)
        
    vpoly.SetVerts(vcells)
    
    return vpoly 
开发者ID:lmb-freiburg,项目名称:demon,代码行数:39,代码来源:vis.py

示例9: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def __init__(self, point_size=18, maxNumPoints=1e8):
        self.maxNumPoints = maxNumPoints
        self.vtkPolyData = vtk.vtkPolyData()
        self.clear_points()

        self.colors = vtk.vtkUnsignedCharArray()
        self.colors.SetNumberOfComponents(3)
        self.colors.SetName("Colors")

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputData(self.vtkPolyData)

        self.vtkActor = vtk.vtkActor()
        self.vtkActor.SetMapper(mapper)
        self.vtkActor.GetProperty().SetPointSize(point_size) 
开发者ID:VisualComputingInstitute,项目名称:3d-semantic-segmentation,代码行数:17,代码来源:viz.py

示例10: create_pointcloud_polydata

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def create_pointcloud_polydata(points, colors=None):
    """https://github.com/lmb-freiburg/demon
    Creates a vtkPolyData object with the point cloud from numpy arrays
    
    points: numpy.ndarray
        pointcloud with shape (n,3)
    
    colors: numpy.ndarray
        uint8 array with colors for each point. shape is (n,3)

    Returns vtkPolyData object
    """
    vpoints = vtk.vtkPoints()
    vpoints.SetNumberOfPoints(points.shape[0])
    for i in range(points.shape[0]):
        vpoints.SetPoint(i, points[i])
    vpoly = vtk.vtkPolyData()
    vpoly.SetPoints(vpoints)
    
    if not colors is None:
        vcolors = vtk.vtkUnsignedCharArray()
        vcolors.SetNumberOfComponents(3)
        vcolors.SetName("Colors")
        vcolors.SetNumberOfTuples(points.shape[0])
        for i in range(points.shape[0]):
            vcolors.SetTuple3(i ,colors[i,0],colors[i,1], colors[i,2])
        vpoly.GetPointData().SetScalars(vcolors)

    vcells = vtk.vtkCellArray()
    
    for i in range(points.shape[0]):
        vcells.InsertNextCell(1)
        vcells.InsertCellPoint(i)
        
    vpoly.SetVerts(vcells)
    
    return vpoly 
开发者ID:princeton-vl,项目名称:DeepV2D,代码行数:39,代码来源:vis.py

示例11: create_pointcloud_polydata

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def create_pointcloud_polydata(points, colors=None):
    """Creates a vtkPolyData object with the point cloud from numpy arrays

    points: numpy.ndarray
        pointcloud with shape (n,3)

    colors: numpy.ndarray
        uint8 array with colors for each point. shape is (n,3)

    Returns vtkPolyData object
    """
    import vtk
    vpoints = vtk.vtkPoints()
    vpoints.SetNumberOfPoints(points.shape[0])
    for i in range(points.shape[0]):
        vpoints.SetPoint(i, points[i])
    vpoly = vtk.vtkPolyData()
    vpoly.SetPoints(vpoints)

    if not colors is None:
        vcolors = vtk.vtkUnsignedCharArray()
        vcolors.SetNumberOfComponents(3)
        vcolors.SetName("Colors")
        vcolors.SetNumberOfTuples(points.shape[0])
        for i in range(points.shape[0]):
            vcolors.SetTuple3(i ,colors[i,0],colors[i,1], colors[i,2])
        vpoly.GetPointData().SetScalars(vcolors)

    vcells = vtk.vtkCellArray()

    for i in range(points.shape[0]):
        vcells.InsertNextCell(1)
        vcells.InsertCellPoint(i)

    vpoly.SetVerts(vcells)

    return vpoly 
开发者ID:sfu-gruvi-3dv,项目名称:sanet_relocal_demo,代码行数:39,代码来源:util.py

示例12: clearPoints

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def clearPoints(self):
        self.vtkPoints = vtk.vtkPoints()
        self.vtkCells = vtk.vtkCellArray()
        self.vtkDepth = vtk.vtkDoubleArray()
        self.vtkDepth.SetName('DepthArray')
        self.vtkPolyData.SetPoints(self.vtkPoints)
        self.vtkPolyData.SetVerts(self.vtkCells)
        self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
        self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')

        self.Colors = vtk.vtkUnsignedCharArray()
        self.Colors.SetNumberOfComponents(3) 
        self.Colors.SetName("Colors") 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:15,代码来源:kinect3Dcould.py

示例13: CreateAxesSimplified

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def CreateAxesSimplified(self, length):
        "Create a simplified coordinate axes system with 3 lines"
        points = vtk.vtkPoints()
        lines = vtk.vtkCellArray()
        colors = vtk.vtkUnsignedCharArray()
        colors.SetNumberOfComponents(3)
        colors.SetName("Colors")

        ptIds = [None, None]
        end_points = length * np.eye(3)
        line_colors = 255 * np.eye(3, dtype="i")
        for i in range(3):
            ptIds[0] = points.InsertNextPoint([0, 0, 0])
            ptIds[1] = points.InsertNextPoint(end_points[i])
            lines.InsertNextCell(2, ptIds)

            colors.InsertNextTuple3(*line_colors[i])
            colors.InsertNextTuple3(*line_colors[i])

        # Add the lines to the polydata container
        self.pd = vtk.vtkPolyData()
        self.pd.SetPoints(points)
        self.pd.GetPointData().SetScalars(colors)
        self.pd.SetLines(lines)

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInputData(self.pd)
        self.mapper.Update()
        self.actor = vtk.vtkActor()
        self.actor.SetMapper(self.mapper) 
开发者ID:poodarchu,项目名称:Det3D,代码行数:32,代码来源:pointobject.py

示例14: show_pcd_ndarray

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def show_pcd_ndarray(array_data, color_arr=[0, 255, 0]):
        all_rows = array_data.shape[0]
        Colors = vtk.vtkUnsignedCharArray()
        Colors.SetNumberOfComponents(3)
        Colors.SetName("Colors")

        Points = vtk.vtkPoints()
        Vertices = vtk.vtkCellArray()

        for k in xrange(all_rows):
            point = array_data[k, :]
            id = Points.InsertNextPoint(point[0], point[1], point[2])
            Vertices.InsertNextCell(1)
            Vertices.InsertCellPoint(id)
            if vtk.VTK_MAJOR_VERSION > 6:
                Colors.InsertNextTuple(color_arr)
            else:
                Colors.InsertNextTupleValue(color_arr)

            dis_tmp = np.sqrt((point ** 2).sum(0))
            # Colors.InsertNextTupleValue([0,255-dis_tmp/max_dist*255,0])
            # Colors.InsertNextTupleValue([255-abs(point[0]/x_max*255),255-abs(point[1]/y_max*255),255-abs(point[2]/z_max*255)])
            # Colors.InsertNextTupleValue([255-abs(point[0]/x_max*255),255,255])

        polydata = vtk.vtkPolyData()
        polydata.SetPoints(Points)
        polydata.SetVerts(Vertices)
        polydata.GetPointData().SetScalars(Colors)
        polydata.Modified()

        mapper = vtk.vtkPolyDataMapper()
        if vtk.VTK_MAJOR_VERSION <= 5:
            mapper.SetInput(polydata)
        else:
            mapper.SetInputData(polydata)
        mapper.SetColorModeToDefault()
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.GetProperty().SetPointSize(5)

        # Renderer
        renderer = vtk.vtkRenderer()
        renderer.AddActor(actor)
        renderer.SetBackground(.2, .3, .4)
        renderer.ResetCamera()

        # Render Window
        renderWindow = vtk.vtkRenderWindow()
        renderWindow.AddRenderer(renderer)

        # Interactor
        renderWindowInteractor = vtk.vtkRenderWindowInteractor()
        renderWindowInteractor.SetRenderWindow(renderWindow)

        # Begin Interaction
        renderWindow.Render()
        renderWindowInteractor.Start()


# determine whether a segment is the potential chessboard's point cloud 
开发者ID:mfxox,项目名称:ILCC,代码行数:62,代码来源:pcd_corners_est.py

示例15: xy_axis

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkUnsignedCharArray [as 别名]
def xy_axis(apoints_path):

    # print a green y-positive and a x-positive line in the centre
    sensor = pd.read_csv(apoints_path)
    mid_x = sensor[['sen_x']].mean(axis=0)
    mid_y = sensor[['sen_y']].mean(axis=0)
    mid_z = sensor[['sen_z']].mean(axis=0)
    min_z = sensor[['sen_z']].min(axis=0)
    max_x = sensor[['sen_x']].max(axis=0)
    max_y = sensor[['sen_y']].max(axis=0)
    pts = vtk.vtkPoints()
    pts.InsertNextPoint([mid_x, mid_y, min_z])
    pts.InsertNextPoint([max_x, mid_y, min_z])
    pts.InsertNextPoint([mid_x, max_y, min_z])
    # Setup two colors - one for each line
    red = [255, 0, 0]
    green = [0, 255, 0]
    colors = vtk.vtkUnsignedCharArray()
    colors.SetNumberOfComponents(3)
    colors.SetName("Colors")
    colors.InsertNextTupleValue(red)
    colors.InsertNextTupleValue(green)
    line0 = vtk.vtkLine()
    line0.GetPointIds().SetId(0, 0)
    line0.GetPointIds().SetId(1, 1)
    line1 = vtk.vtkLine()
    line1.GetPointIds().SetId(0, 0)
    line1.GetPointIds().SetId(1, 2)
    lines = vtk.vtkCellArray()
    lines.InsertNextCell(line0)
    lines.InsertNextCell(line1)
    linespolydata = vtk.vtkPolyData()
    linespolydata.SetPoints(pts)
    linespolydata.SetLines(lines)
    linespolydata.GetCellData().SetScalars(colors)
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInput(linespolydata)
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    mid_point = [mid_x, mid_y, mid_z]

    return actor, mid_point 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:44,代码来源:visualization.py


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