Reputation: 35
So I'm working on a 3D scanner, and I made some 3D reconstruction code.
Here is the code.
But because I'm more of a noob, I'm not sure how I could export the point cloud, and afterwards use it a 3d modelling program, like blender.
Upvotes: 1
Views: 13855
Reputation: 23
As David de la Iglesia said, you can use the https://github.com/daavoo/pyntcloud package. But the way he did it the color doesn't work because it's in the float format, due to stacking it together with the coordinates.
d = {'x': points[:,0],'y': points[:,1],'z': points[:,2],
'red' : colors[:,0], 'green' : colors[:,1], 'blue' : colors[:,2]}
cloud = PyntCloud(pd.DataFrame(data=d))
cloud.to_file("output.ply")
The matrix "points" is in float format and "colors" in uint8
Upvotes: 2
Reputation: 2534
I cant be sure without having a example of the result of the 3D reconstruction, but based on the code you linked to I think that you could generate a .ply file ready to be imported to Blender as follows:
Using https://github.com/daavoo/pyntcloud.
import numpy as np
import pandas as pd
from pyntcloud import PyntCloud
cloud = PyntCloud(pd.DataFrame(
# same arguments that you are passing to visualize_pcl
data=np.hstack((points, colors)),
columns=["x", "y", "z", "red", "green", "blue"]))
cloud.to_file("output.ply")
Upvotes: 9
Reputation: 3657
You can import PLY format and OBJ format into Blender both support ASCII files. Write out the appropriate ASCII file with the appropriate headers & as long as you have the format correct they should be readable by programs that support PLY & OBJ.
Alternatively you could use Python's CSV library save your data as a CSV file and import into Blender as a CSV using Blenders Python API.
Upvotes: 1