-
Hi! My algorithm runs through the point cloud and classifies points into classes using different colours, and I want to see how those classifications evolve by periodically updating the vedo viewer. So, in this situation, the position of the points in constant between refreshes. I've done a little debugging and found that the line seems to really take a long time during each update cycle is the following:
in the above line "colour_array" is a list of RGB triplets, one triplet for each point in the cloud. Is this the best way to update the colors of the cloud? Any suggestions you may have to optimise the speed here would be very gratefully accepted. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi, thanks for your nice words, the problem is that you recreate from scratch the whole import vedo as ve
import numpy as np
ve.settings.defaultFont = "Theemim"
plt = ve.Plotter(interactive=False)
# Initialise the point could
points = np.random.rand(1000,3)
pcd = ve.pointcloud.Points(points, r=10)
pcd.pointdata["MY_RGB"] = np.zeros([1000,3], dtype=np.uint8)
pcd.pointdata.select("MY_RGB") # can add an alpha channel too
plt += [pcd, ve.Axes(pcd)]
plt.show()
pb = ve.ProgressBar(0, 500)
for n in range(500):
colour_array = np.random.rand(pcd.NPoints(), 3)
colour_array /= (np.max(colour_array) / 255) # normalize correctly
colour_array = colour_array.astype(np.uint8) # this will save memory
pcd.pointdata["MY_RGB"] = colour_array
# update the loop here
plt.render()
pb.print()
ve.interactive() which runs at about 60Hz on my pc. |
Beta Was this translation helpful? Give feedback.
Hi, thanks for your nice words, the problem is that you recreate from scratch the whole
Points
object. I would it this way: