[Addon] Point Cloud Visualizer


(carbon2) #1

Point Cloud Visualizer

blender 2.80 update:
Display colored point cloud PLY in Blender’s 3d viewport. Works with binary point cloud PLY files with ‘x, y, z, red, green, blue’ vertex values. All other values are ignored. Color values must be in 0-255 range.

Point Cloud Visualizer

  • Usage: Install and activate addon in a usual way. Add any object to scene. Go to 3d View Sidebar (N) > ‘Point Cloud Visualizer’ panel, click file browser icon, select ply file, click ‘Load PLY’. Click ‘Draw’ button to display point cloud, ‘Erase’ to hide point cloud. Adjust percentage of displayed points with ‘Display’ and point size with ‘Radius’.
  • Transforming parent object transforms point cloud as well.
  • Huge speed improvements compared to 2.7x version.

changelog:

  • 0.4.5 added ‘Display’ percentage, better error handling during .ply loading
  • 0.4.0 almost complete rewrite for blender 2.80, performance improvements using shaders, simplified ui

get it here:
https://raw.githubusercontent.com/uhlik/bpy/master/view3d_point_cloud_visualizer.py




for blender 2.7x

Display colored point cloud PLY in Blender’s 3d viewport. Works with binary point cloud PLY files with ‘x, y, z, red, green, blue’ vertex values. All other values are ignored. Color values must be in 0-255 range (8 bit).

https://raw.githubusercontent.com/uhlik/bpy/master/x/pc.gif

  • Add an Empty object
  • Load and display point cloud at Properties (N) panel with Empty selected
  • Available controls: auto loading of selected ply file, pixel point drawing or OpenGL smooth point, drawing enable/disable, percentage of displayed points and reset button which resets all (except autoload option)
  • Transforming Empty transforms point cloud as well
  • Works reasonably fast with 4m points on my machine, 2 years old, not top of the line

update: added display percentage

changelog:

  • 0.3.0 new ply loader, can be used with any binary ply file with vertex coordinates and colors
  • 0.2.0 display percentage
  • 0.1.0 first release

direct link:


https://raw.githubusercontent.com/uhlik/bpy/master/2.7x/view3d_point_cloud_visualizer.py


(Spirou4D) #2

Congratulations carbon2,
One more time, a very useful addon!
Friendly yours.
Namaste. :eyebrowlift:
Spirou4D


(SniperKing) #3

It’s amazing !!! :cool:
Thanks


(irSindaco) #4

I’ve been looking for this for months now. Thanks carbon2, well done :slight_smile:


(urkokul) #5

Awesome. Thanks


(carbon2) #6

update: added display percentage


(nirenyang) #7

Nice point cloud tool. hope somedays blender can import huge color pointcloud like recap.


(SniperKing) #8

Great, this new feature :slight_smile:

For information, ambient occlusion works on the cloud (my first test with photoscan trial version) :wink:
OpenGL render don’t work. Why ? Do you have a solution ?



(carbon2) #9

opengl render (i guess) is out of reach from python, so i don’t think it is possible. 3d manipulators are not rendered too.


(SniperKing) #10

For turn around this problem, it’s possible to take bgl captures!!! It’s works perfectly ! :smiley:


(carbon2) #11

update: 0.3.0 new ply loader, can be used with any binary ply file with vertex coordinates and colors
from now it should load any binary ply with ‘x, y, z, red, green, blue’ vertex values. all other values are ignored. color values must be in 0-255 range.


(CHBB) #12

Awesome work!

But how to load a file automatically from python scripts? Setting the file path works:

bpy.data.objects[“empty”].point_cloud_visualizer.filepath = r’’‘path o\file.ply’’’

Loading the pc file by changing the default value for automatic loading to true is not working


(stephen_leger) #13

Hi carbon2,
Nice work !
For opengl render under python you may take a look at MesureIt or archipack [1], (sharing same codebase).
The trick is to use gl to draw over an image rather than on screen.
Keep in mind that blender gl api is likely to deeply change under 2.8 (complete rewrite, not yet done).

[1] archipack gl render


(carbon2) #14

i don’t think i understand, for rendering like on image right? not rendering to viewport, or there is some performance black magic, drawing all to in memory image and then the drawing image over viewport to speed things up…


(artao) #15

So I’m very excited about this add-on, as I NEED vert colors from point clouds for what I’m trying to do.
I’m using Mandelbulb 3D to generate point clouds of 3D fractals to import into Blender for volumetric rendering in cycles and renderman. Mandelbulb 3D bases the vert colors on the fractally calculated colors, which is important. “Faking” that sort of thing just isn’t really possible.
So I’ve installed this … I think … All I need is the second link you listed, yes? I tried downloading the .zip from the first GitHub link, but Blender wouldn’t accept that for an install.
When I try to load my .ply files, I’m told “Unable to load .ply”
Here is one of my point clouds I’m attempting to import. This is a pretty small one. Just a default formula for test export. Some of the point clouds .ply files are over 150 megs, and I’m sure I could easily go bigger.
https://drive.google.com/open?id=1Boa4KLp1Hwf4FEcY89GU-IM5kr1jV__x

I very much look forward to be able to use this add-on.

… I even tried running the .ply thru MeshLab and exporting it as Collada, but Blender still didn’t bring in the vert colors.


(carbon2) #16

the first link is my repo of all addons, it can’t be installed as a whole. the second link is addon itself.
but seems like you sorted it out and successfully installed addon, now the ply files. the ply you linked is ascii ply file and only binary ply files works in my addon. it has ply reader built in and it accepts only binary encoded ply files, so if you can save them as binary or in meshlab load your ascii ply, save as ply again, this time with binary encoding checked and you are good to go. i tested it with your file and works well.
by the way, with binary encoding you get much smaller file sizes…


(artao) #17

Okay thanks. That worked to get it into your visualizer, and the colors do indeed come through nicely.
Is there a way for me to apply that to a volumetric material?
While trying to figure if/how I could do that, it crashed and gave me this error, which I duly report:

Traceback (most recent call last):
File “C:\Users\freeman\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\view3d_point_cloud_visualizer.py”, line 299, in modal
context.area.tag_redraw()
AttributeError: ‘NoneType’ object has no attribute ‘tag_redraw’

location: <unknown location>:-1

ALSO! Thanks for the tip about the binary file. I didn’t realize Mandelbulb 3D was outputting text. And no, there is no binary option, sadly.


(carbon2) #18

can you provide some steps to reproduce the error? such errors does not say much. it might be for example, that you switched are type from viewport to something else while drawing pointcloud. documentation about drawing to viewport is kinda non existent…


(stephen_leger) #19

Hi carbon2,
bgl is able to draw over viewport and over any image.
No black magick here, in MesureIt, the code draw gl only part over a black empty image and then composite with regular render.
This way you may add gl over any regular render, regardless of render engine used.


(artao) #20

Sorry, no. It has only happened once, and I don’t remember exactly what series of steps I had done that resulted in that.
Any tips on using those vertex colors as the source for volumetric colors?
What I’m trying to do is use point clouds of fractals to create volumetrics in Blender, and really kinda need the colors from the fractals as well.