# Python VTK -- Can we get the mesh rendered from the colorized point cloud

**URL:** https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200
**Category:** Support
**Created:** [February 1, 2019, 8:07pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200 "2019-02-01T20:07:56Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [February 1, 2019, 8:07pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/1 "2019-02-01T20:07:56Z")

</div>

Hello,

I am going to capture different images from different viewpoint pose of virtual camera in Python VTK. When I set a close viewpoint to the point cloud, the point cloud became sparse and I could not get a good image to reflect the original color. When I set the viewpoint far from the point cloud, I could get a better image. I am wondering if there a way to first render the colorized point cloud and we can capture the image from different pose, but remain the image quality. Thanks.

![shot_1](https://discourse.vtk.org/uploads/default/original/1X/dbd35d7bb3da5d76030411400d7a941114589d35.png) ![shot_2](https://discourse.vtk.org/uploads/default/original/1X/9e04d7ace6d7951aea73fc5c318eb757d16a5a13.png) ![shot_3](https://discourse.vtk.org/uploads/default/original/1X/b3b75b72dfd740b93bdf7b44a4022ea88a543047.png) ![shot_4](https://discourse.vtk.org/uploads/default/original/1X/5e641d7f431532d12052a32716aef38172c31f9f.png)

---

<div class="post-metadata">

### Author: ![TravStu22](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@TravStu22](https://discourse.vtk.org/u/TravStu22)
#### Post date: [February 2, 2019, 1:12pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/2 "2019-02-02T13:12:20Z")

</div>

You could render the points as spheres with diameters large enough that there is no gap between points.

---

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [February 2, 2019, 7:13pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/3 "2019-02-02T19:13:37Z")

</div>

Thanks for your reply.

I try with my code but it is too slow to view all the points. I need to process at most 1 million point cloud (at least 100000) – large data sets. Any faster method for rendering the colorized point cloud (convert to sphere)? Thanks.

This is my code:

# Load the spherical model  
test = BTL\_GL.BTL\_GL()  
pcd, pc, pc\_color = test.GL\_NonFlat()

sphere = vtk.vtkSphereSource()  
sphere.SetThetaResolution(100)  
sphere.SetPhiResolution(50)  
sphere.SetRadius(0.0025)  
sphereMapper = vtk.vtkPolyDataMapper()  
sphereMapper.SetInputConnection(sphere.GetOutputPort())  
spheres = list()

N = 2000

for i in range(N):

npy\_spot = np.asarray([pc[i,0], pc[i,1], pc[i,2]])  
 npy\_color = np.asarray([pc\_color[i,&#32;0], pc\_color[i,&#32;1], pc\_color[i,&#32;2]])  
 spheres.append(vtk.vtkActor())  
 # spheres[i].SetRadius(0.05)  
 spheres[i].SetMapper(sphereMapper)  
 spheres[i].GetProperty().SetColor(npy\_color[0] / 255, npy\_color[1] / 255, npy\_color[2] / 255)  
 spheres[i].AddPosition([npy\_spot[0], npy\_spot[1], npy\_spot[2]])

ren = vtk.vtkRenderer()  
renWin = vtk.vtkRenderWindow()  
renWin.AddRenderer(ren)  
iren = vtk.vtkRenderWindowInteractor()  
iren.SetRenderWindow(renWin)

for i in range(0, N):  
 ren.AddActor(spheres[i])

ren.SetBackground(0.2, 0.3, 0.4)  
renWin.SetSize(640, 480)  
renWin.SetWindowName(“Specular Spheres”)

iren.Initialize()  
renWin.Render()  
iren.Start()

---

<div class="post-metadata">

### Author: ![TravStu22](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@TravStu22](https://discourse.vtk.org/u/TravStu22)
#### Post date: [February 2, 2019, 9:20pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/4 "2019-02-02T21:20:58Z")

</div>

Yes. Adding a new sphere actor to the renderer for each point is not efficient. Instead, create only one sphere actor and map it to each point with vtkGlyph3DMapper. Something like this:

```
sphere = vtk.vtkSphereSource()
sphere.SetPhiResolution(5)
sphere.SetThetaResolution(5)
sphere.SetRadius(0.0025)

#add your point coordinates to the poly data... along with a field to specify the point color?
point_poly_data = vtk.vtkPolyData()

point_mapper = vtk.vtkGlyph3DMapper()
point_mapper.SetInputData(point_poly_data)
point_mapper.SetSourceConnection(sphere.GetOutputPort())
#you'll need to do something more here to map the point colors I think

actor = vtk.vtkActor()
actor.SetMapper(point_mapper)
actor.GetProperty().LightingOff()
actor.GetProperty().BackfaceCullingOn()

vtk_renderer.AddActor(actor)
```

---

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [February 2, 2019, 11:43pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/5 "2019-02-02T23:43:52Z")

</div>

Thanks for your reply. I write the code and debug for a long time but still not able to get the colorized sphere. Here is my code:

# Load the data  
nc = vtk.vtkNamedColors()  
test = BTL\_GL.BTL\_GL()  
pcd, pc, pc\_color = test.GL\_NonFlat()

# The sphere model  
sphere = vtk.vtkSphereSource()  
sphere.SetPhiResolution(5)  
sphere.SetThetaResolution(5)  
sphere.SetRadius(0.0025 \* 2)

Points = vtk.vtkPoints()

Colors = vtk.vtkUnsignedCharArray()  
Colors.SetNumberOfComponents(3)  
Colors.SetName(“Colors”)  
Colors.InsertNextTuple3(255,0,0)

for i in range(len(pc)):  
 Points.InsertNextPoint(pc[i,&#32;0], pc[i,&#32;1], pc[i,&#32;2])  
 Colors.InsertNextTuple3(pc\_color[i,&#32;0] / 255, pc\_color[i,&#32;1] / 255, pc\_color[i,&#32;2] / 255)

polydata = vtk.vtkPolyData()  
polydata.SetPoints(Points)  
sphere.GetOutput().GetCellData().SetScalars(Colors)  
sphere.Update()

appendData = vtk.vtkAppendPolyData()  
appendData.AddInputConnection(sphere.GetOutputPort())  
appendData.Update()

point\_mapper = vtk.vtkGlyph3DMapper()  
point\_mapper.SetInputData(polydata)  
point\_mapper.SetSourceConnection(appendData.GetOutputPort())

# Set background color  
actor = vtk.vtkActor()  
actor.SetMapper(point\_mapper)  
actor.GetProperty().LightingOff()  
actor.GetProperty().BackfaceCullingOn()

ren = vtk.vtkRenderer()  
ren.SetBackground(.2, .3, .4)  
ren.AddActor(actor)

renWin = vtk.vtkRenderWindow()  
renWin.AddRenderer(ren)

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

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

---

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [February 11, 2019, 12:51pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/6 "2019-02-11T12:51:37Z")

</div>

I see 3 possibilities:

1. use `actor.GetProperty().RenderPointsAsSpheresOn()` somewhere in your code.
2. this works for me, using `vtkVertexGlyphFilter` :

```python
import vtk

# Load the data for point cloud and colorized vectors
# nc = vtk.vtkNamedColors()
# test = BTL_GL.BTL_GL()
# pcd, pc, pc_color, MeshGrid, img_color = test.GL_NonFlat()
n = 10
src = vtk.vtkPointSource()
src.SetNumberOfPoints(n)
src.Update()

vgf = vtk.vtkVertexGlyphFilter()
vgf.SetInputData(src.GetOutput())
vgf.Update()
pcd = vgf.GetOutput()

ucols = vtk.vtkUnsignedCharArray()
ucols.SetNumberOfComponents(3)
ucols.SetName("Colors")
for i in range(n):
    ucols.InsertNextTuple3(255,i*30,i*30)
pcd.GetPointData().SetScalars(ucols)

# Design the mapper
point_mapper = vtk.vtkPolyDataMapper()
point_mapper.SetInputData(pcd)

actor = vtk.vtkActor()
actor.SetMapper(point_mapper)
actor.GetProperty().SetPointSize(10)
actor.GetProperty().RenderPointsAsSpheresOn()

ren = vtk.vtkRenderer()
ren.SetBackground(.2, .3, .4)
ren.AddActor(actor)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)

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

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

```

![cols](https://discourse.vtk.org/uploads/default/original/1X/2cf640b2339fddef550a5574aed52dcc87f84f8e.png)

1. use example in [https://github.com/marcomusy/vtkplotter/blob/master/examples/basic/manyspheres.py](https://github.com/marcomusy/vtkplotter/blob/master/examples/basic/manyspheres.py)

---

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [February 11, 2019, 4:36pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/7 "2019-02-11T16:36:20Z")

</div>

Great appreciate the examples. I think the code is working so far but some small problems still exist such as

1. Point distance is large in some region (we can still see some wide space between points in the edge). For some dense point cloud, this problem is more obvious and I am thinking another method to first reconstruct the point cloud surface and assign the color. But it seems not working well, as shown in fig. 1.
2. I try with generating with the mesh with point index and triangular mesh, but it seems not working well and I am not sure if this is the problem that I didn’t change the property of the mesh, as shown in fig. 2.
3. When we get close to the object, we can see the artifacts on the dense mesh grid. I am thinking maybe using OpenGL texture mapping might be another possible solution?
4. I am thinking about using stl and look up table to assign the color vector to the points.

Any improvements are welcomed. Thanks again.

I have finished the code:

 ![demo_2](https://discourse.vtk.org/uploads/default/original/1X/3839e66059910ffa7ba42321271e0d6af6938ce0.jpeg)  
 ![demo_1](https://discourse.vtk.org/uploads/default/original/1X/25a2efdaa07818a4352d5abcd38cafdb98df125c.jpeg)  
 ![demo](https://discourse.vtk.org/uploads/default/original/1X/2fd74f70c5e6c1d956384553b9b44d3996fef5ad.jpeg)  
 ![9](https://discourse.vtk.org/uploads/default/original/1X/12facb191990fc2c67142bda19e749e74e5efed5.png)

# Load the data object  
‘’’  
pcd: object of pcd  
pc: point coordinates, M x 3  
pc\_color: color vectors, M x 3  
img\_color: color image for textured mapping  
‘’’

test = BTL\_GL.BTL\_GL()  
pcd, pc, pc\_color, MeshGrid, img\_color = test.GL\_NonFlat()

# Define the points polydata  
points = vtk.vtkPoints()  
for i in range(len(pc)):  
 points.InsertNextPoint(pc[i,&#32;0], pc[i,&#32;1], pc[i,&#32;2])  
polydata = vtk.vtkPolyData()  
polydata.SetPoints(points)

# Define the color to the polydata  
colors = vtk.vtkUnsignedCharArray()  
colors.SetNumberOfComponents(3)  
colors.SetNumberOfTuples(polydata.GetNumberOfPoints())  
for i in range(len(pc\_color)):  
 colors.InsertTuple3(i, pc\_color[i,&#32;0], pc\_color[i,&#32;1], pc\_color[i,&#32;2])

# Connect the point object to the color object  
polydata.GetPointData().SetScalars(colors)

# Define the VertexGlyphFilter  
vgf = vtk.vtkVertexGlyphFilter()  
vgf.SetInputData(polydata)  
vgf.Update()  
pcd = vgf.GetOutput()

# Define the mapper  
point\_mapper = vtk.vtkPolyDataMapper()  
point\_mapper.SetInputData(pcd)

# Define the actor  
actor = vtk.vtkActor()  
actor.SetMapper(point\_mapper)  
actor.GetProperty().SetPointSize(10)  
actor.GetProperty().RenderPointsAsSpheresOn()

ren = vtk.vtkRenderer()  
ren.SetBackground(.2, .3, .4)  
ren.AddActor(actor)

renWin = vtk.vtkRenderWindow()  
renWin.AddRenderer(ren)

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

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

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [February 27, 2019, 2:12am UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/8 "2019-02-27T02:12:12Z")

</div>

What about simply triangulating your mesh? Be sure your projection plane makes sense before applying the triangulation filter.

Also, can you share these files?

---

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [February 27, 2019, 9:15pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/9 "2019-02-27T21:15:18Z")

</div>

Yes sure, I have an algorithm working but not the best solution. The whole work flow is shown in the following steps:

1. Read a stl file (.stl) as a 3D model, called model A
2. Read a image file (.png or .jpg)
3. According to the image size and the shape of the stl file, create a meshgrid for color interpolation. Thus we create a 3D model with color textured, called model B.
4. For each point in the model A, assign the color vector to this point in the meshgrid with the “nearest” point found in the model B.
5. Use look up table for stl color visualization.

Note: I am not allowed to attach files so I upload with the google drive link (.stl files and color.npy):  
[https://drive.google.com/drive/folders/1Qa9kysHJPxWXejoeTUjJYQW5-hI0vDSO?usp=sharing](https://drive.google.com/drive/folders/1Qa9kysHJPxWXejoeTUjJYQW5-hI0vDSO?usp=sharing)

The code is shown in the following. It is a little bit complicated so I only show the main function here, attached with the necessary .npy files:

# Show the colorized stl file  
# Generate the stl model – we need to first know the color vector of the objects  
f = vtk.vtkSTLReader()  
f.SetFileName(self.stl\_path) // here, use the path of the .stl file, attached with this link  
f.Update()

# Update the frame rate  
obj = f.GetOutputDataObject(0)  
min\_z, max\_z = obj.GetBounds()[4:]

lut = vtk.vtkLookupTable()  
lut.SetTableRange(min\_z, max\_z)  
lut.Build()

heights = vtk.vtkDoubleArray()  
heights.SetName(“Z\_Value”)

# Load the color object  
Colors = vtk.vtkUnsignedCharArray()  
Colors.SetNumberOfComponents(3)  
Colors.SetName(“Colors”)

# Load the color stl file (N x 3 vector)  
COLOR = np.load(self.colorstl\_file) // here, use the path of the color.npy file, attached with this link

for i in range(obj.GetNumberOfPoints()):  
 z = obj.GetPoint(i)[-1]  
 Colors.InsertNextTuple3(COLOR[i,&#32;0], COLOR[i,&#32;1], COLOR[i,&#32;2])

obj.GetPointData().SetScalars(Colors)

mapper = vtk.vtkPolyDataMapper()  
mapper.SetInputDataObject(obj)  
mapper.SetScalarRange(min\_z, max\_z)  
mapper.SetLookupTable(lut)

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

renderer = vtk.vtkRenderer()  
renderer.AddActor(actor)  
renderer.SetBackground(.1, .2, .4)

renw = vtk.vtkRenderWindow()  
renw.AddRenderer(renderer)

iren = vtk.vtkRenderWindowInteractor()  
iren.SetRenderWindow(renw)

renw.Render()  
iren.Start()

I am still looking for a better way to do that. There are several problems:

1. image resolution attached with the triangulation mesh in the stl file
2. I am still figuring out a way to use triangulation filter.

 ![demo_1](https://discourse.vtk.org/uploads/default/original/1X/5420b654a89369d88869c8cebf22f13287216647.jpeg)

 ![demo_2](https://discourse.vtk.org/uploads/default/original/1X/daaf3d4c50e2e5456d341288e5a54aa63e254606.jpeg)

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [February 27, 2019, 9:22pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/10 "2019-02-27T21:22:27Z")

</div>

Can you give me the original image (the PNG or JPEG)?

---

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [February 27, 2019, 9:30pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/11 "2019-02-27T21:30:21Z")

</div>

Yes sure. It is uploaded on the google link. It is a regular .jpg lena image with dimension as 458x447x3.

![lena](https://discourse.vtk.org/uploads/default/original/1X/99ece7795509e43a1e49c86f94c87d7ee6756cb1.jpeg)

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [February 27, 2019, 9:33pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/12 "2019-02-27T21:33:14Z")

</div>

You ought to try **texture mapping** rather than giving every point an RGB value. Also, VTK in python is streamlined with the [`vtki`](http://docs.vtki.org/en/latest/) Python package (`pip install vtki`):

Try this:

```python
import vtki
import numpy as np
from vtki import examples

# Load a dummy texture
texture = examples.load_globe_texture()
# or load your own texture
# texture = vtki.read_texture('image.jpeg')

# Update the frame rate
obj = vtki.read('hemis_150.stl')
# Texture map to the best fitting plane
obj.texture_map_to_plane(inplace=True)

obj.plot(texture=texture, screenshot='image.png')

```

 ![image](https://discourse.vtk.org/uploads/default/original/1X/8b9891b95052cc5bc5d04080cb79d7aaef648f65.jpeg)

 ![image2](https://discourse.vtk.org/uploads/default/original/1X/6557055ff65cfe69d6c04526e0161663afe2f3a6.png)

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [February 28, 2019, 10:17pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/13 "2019-02-28T22:17:08Z")

</div>

As an aside to the main discussion here, I suggest looking up the controversy over using the Lena image for examples. In the interests of having a community welcoming to all, I suggest using a different example image in this forum.

---

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [March 9, 2019, 10:50pm UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/14 "2019-03-09T22:50:49Z")

</div>

Great thanks for your reply. I am wondering if we can automatically capture the screen shots based on different camera angles. Since we are using vtki and vtk, it is easy to obtain different camera position in vtk but it might be difficult in vtki. I am wondering if there a more convenient way to obtain the data object stored in vtki object, such as vtkpoly data, etc, and use it with the vtk objects. I tried with my code but it is not getting any results:

```
    texture = vtki.load_texture(img_path)
    obj = vtki.read(stl_path)
    obj.texture_map_to_plane(inplace=True)
    # obj.plot(texture = texture, screenshot='image.png')

    Mapper = vtk.vtkPolyDataMapper()
    Mapper.SetInputData(obj)
    Actor = vtk.vtkActor()
    Actor.SetMapper(Mapper)

    renderer = vtk.vtkRenderer()
    renderer.AddActor(Actor)
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(renderer)

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    renWin.Render()
    iren.Start()
```

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [March 10, 2019, 7:34am UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/15 "2019-03-10T07:34:26Z")

</div>

> [@ljc19800331](#):
>
> I am wondering if we can automatically capture the screen shots based on different camera angles … but it might be difficult in vtki

It’s quite easy. The camera position can be accessed and changed when plotting in `vtki` under the `camera_position` attribute of the [plotter](http://docs.vtki.org/en/latest/tools/plotting.html#base-plotter). Also, there are several convenience functions to view common perspectives (e.g. `.view_xy()`). Perhaps you’d benefit from some of the examples in the docs like [this one](http://docs.vtki.org/en/latest/examples/quick/load-file.html). `vtki` also has a powerful [background plotter](http://docs.vtki.org/en/latest/tools/qt_plotting.html#background-plotting) that has a GUI for saving/loading camera positions.

> [@ljc19800331](#):
>
> I am wondering if there a more convenient way to obtain the data object stored in vtki object, such as vtkpoly data, etc, and use it with the vtk objects.

**`vtki` data objects are subclasses of VTK data objects** so any `vtki` data object will work seamlessly with VTK as we only provide a wrapping on top of the VTK data object. This wrapping doesn’t alter or convert the data, it simply provides numpy array access and convenience functions to get information from the dataset. There’s no need to “obtain the data object” as the `vtki` objects are instances of VTK data objects and can be treated as such.

> [@ljc19800331](#):
>
> I tried with my code but it is not getting any results:

Could you be more specific? The code you show should run and produce a visualization without error. If you’d like to apply the texture, you’ll have to do a bit more if using VTK for the rendering… try passing the texture you loaded to the actor: `Actor.SetTexture(texture)` and `Mapper.SetScalarModeToUsePointFieldData()`

---

<div class="post-metadata">

### Author: ![ljc19800331](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ljc19800331/32/367_2.png) [@ljc19800331](https://discourse.vtk.org/u/ljc19800331)
#### Post date: [March 11, 2019, 12:27am UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/16 "2019-03-11T00:27:55Z")

</div>

Thank you so much for your help. I finished the code and the function works well.

# Get the camera coordinate in the spherical model – this is important  
angle\_Azimuth = x\_mesh[i]  
angle\_Elevation = y\_mesh[j]  
camera = vtk.vtkCamera()  
camera.SetPosition(50, 50, 150) # We define the x as the radius to the spherical model – this is im  
camera.SetFocalPoint(50, 50, 0)  
camera.Azimuth(angle\_Azimuth) # 0 to 45 with 5 as uniform sample  
camera.Elevation(angle\_Elevation) # 0 to 45 with 5 as uniform sample  
camera.Roll(0) # no rolling in consideration – this is im  
cam\_coordinate = camera.GetPosition()  
print("The camera coordinate is ", cam\_coordinate)

focal\_coordinate = (50.0, 50.0, 1.0)  
plotter.camera\_position = [cam\_coordinate, focal\_coordinate, (0.0, 1.0, 0.0)]  
cam = plotter.camera\_position

# Define the camera model – this is important  
p\_center = cam\_coordinate  
p\_direction = np.asarray(cam\_coordinate) - np.asarray(focal\_coordinate)  
p\_scale = (1, 1, 1)  
camActor = actor\_camera(p\_center, p\_direction, p\_scale)

# plotter.add\_actor(camActor)  
img\_path = ‘creenshot/’ + str(angle\_Azimuth) + ‘\_’ + str(angle\_Elevation) + ‘.png’  
plotter.screenshot(img\_path)

 ![demo](https://discourse.vtk.org/uploads/default/original/1X/b0d3f447dd12bb338ed0c65d0b90fbe667dd1e87.jpeg)

---

<div class="post-metadata">

### Author: ![selvakarna](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/71c47a/32.png) [@selvakarna](https://discourse.vtk.org/u/selvakarna)
#### Post date: [April 9, 2019, 5:08am UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/17 "2019-04-09T05:08:45Z")

</div>

how to make STL ASCII from x y z volume co-ordinates ?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [April 9, 2019, 7:37am UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/18 "2019-04-09T07:37:25Z")

</div>

Please open your own topic.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [April 9, 2019, 7:37am UTC](https://discourse.vtk.org/t/python-vtk-can-we-get-the-mesh-rendered-from-the-colorized-point-cloud/200/19 "2019-04-09T07:37:30Z")

</div>


