Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Plotly 3D model from Photoscan format

I would like to use Plotly in an ipython notebook to visualize a model and/or points cloud created from from Photoscan.

Here is the problem:
Photoscan exports its points cloud in these formats:
class PhotoScan.PointsFormat
Point cloud format in [PointsFormatOBJ, PointsFormatPLY, PointsFormatXYZ, PointsFormatLAS, PointsFormatExpe,
PointsFormatU3D, PointsFormatPDF, PointsFormatE57, PointsFormatOC3, PointsFormatPotree,
PointsFormatLAZ, PointsFormatCL3, PointsFormatPTS, PointsFormatDXF]

Photoscan exports its models in these formats:
class PhotoScan.ModelFormat
Model format in [ModelFormatOBJ, ModelFormat3DS, ModelFormatVRML, ModelFormatPLY, ModelFormatCOLLADA,
ModelFormatU3D, ModelFormatPDF, ModelFormatDXF, ModelFormatFBX, ModelFormatKMZ,
ModelFormatCTM, ModelFormatSTL, ModelFormatDXF_3DF, ModelFormatTLS]

I have not been able to find a way to convert any of these (ideally one PointsFormat and one ModelFormat) into something that plotly will load via the python API.

I do not have deep experience with these formats so am reaching out to the community to see if anyone else has experience with them. I did find one plotly user who imported the PLY format into plotly via the R api ( geomorph::read.ply() ).

Any ideas would be greatly appreciated. Thanks.

@MManning Here you have an example of reading a ply file in Python and plotting data with Plotly. plyfile can read/write a ply file:

thanks! that mostly worked!!

I am able to get a points display to work but not the meshes.

the issue that I am having is the translation done in the cell below the
title “Define the lists of mesh end edges:” where he builds the x,y,z
arrays. I cant seem to get the original notebook to run in my environment
so that I can debug the resulting structures. if you have any guidance on
the how that translation works or the shape of the resulting structures it
would be very helpful.

if there is another issue it is that the viewer is limited wrt the amount
of data it can handle, I have to cut my arrays down significantly to get
the viewer to load the data. Any ideas here?

thanks again, the points look very nice in the window.

Maurice M. Manning

Berkeley Research Computing

UC Berkeley

@MManning It seems that you stopped at plotting the triangle sides of the mesh. The triangle sides are defined as an instance of Scatter3d, mode='lines'. To draw a segment of line plotly requires the lists of x, y, and z-coordinates of its ends. So we pass to Scatter3d the lists of x, y, respectively z-coordinates of all triangle vertices defining our mesh.
For a particular triangle, T, of vertices T[0], T[1], T[2] we append to the list Xe, the x-coordinates of T[0], T[1], T[2], T[0] and None (similarly for y and z-coordinates).