Python, Command Line, EXTRACT_VERTICES to Compute Cloud to Mesh Distance (c2m_dist)

If you are allergic to bug trackers, you can post here any remarks, issues and potential bugs you encounter
Post Reply
spherical
Posts: 3
Joined: Mon Jan 21, 2019 11:11 am

Python, Command Line, EXTRACT_VERTICES to Compute Cloud to Mesh Distance (c2m_dist)

Post by spherical »

Hello,

I'm trying to run the command line version of CloudCompare via Python 3 in order to compute distances between a point cloud generated from one mesh (a 3D bone surface segmentation, generated from CT images) and another mesh (3D air surface segmentation) using -C2M_DIST. I'm using CloudCompare 2.10.1 (edge) on ubuntu 16.04 LTS.

My problem is similar to this older question.

If I sample the bone mesh to generate a point cloud and then compute distances to the air mesh, everything works fine:

Code: Select all

cloudcompare.CloudCompare -SILENT -AUTO_SAVE ON -NO_TIMESTAMP -C_EXPORT_FMT PLY -O /path/to/bone.ply -SAMPLE_MESH POINTS 100000 -O /path/to/air.ply
I can extract the distance data without problems this way, and use them to compute various statistical measures, plot histograms and so on. But as in the thread linked above, I need to be able to visualize the results using the original mesh.

So I'd like to use the vertices of the bone mesh instead of sampling using a certain number or density of points. If I can obtain the distances computed for all vertices, I can use this information to then color the vertices of the original bone mesh. Since CloudCompare 2.10.1 is available for Linux now, I was hoping I could use -EXTRACT_VERTICES for this.

In the wiki, the command is listed as:

Code: Select all

-EXTRACT_VERTICES {method} {parameter}
But I'm assuming that method and parameter were only copied from -SAMPLE_MESH and it should be -EXTRACT_VERTICES only, without any parameters?

What would a minimalist way to use -EXTRACT_VERTICES look like? Shouldn't it just be:

Code: Select all

cloudcompare.CloudCompare -O /path/to/bone.ply -EXTRACT_VERTICES 
Because I tried whatever I could think of. Using it with and without parameters, different positions (before/after file to open and so on), opening the air mesh afterwards and computing the cloud to mesh distances all in a single line, etc.

But I'm either getting Unknown or misplaced command: '-EXTRACT_VERTICES' or I don't find any saved files. I'm assuming a .bin file should be saved if successful.

Should -EXTRACT_VERTICES work when using the command line version of CloudCompare 2.10.1 (edge) for Linux? Or when using the stable or beta versions, which I also tried without success? If it should work, how?
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Python, Command Line, EXTRACT_VERTICES to Compute Cloud to Mesh Distance (c2m_dist)

Post by daniel »

Oops, you are right, the -EXTRACT_VERTICES option is not accessible in the current 2.10.1 version! It's a bug...

As a reward, I modified the C2M_DIST command so that it can work with 2 meshes (in which case CC will consider the first mesh vertices as the compared cloud).

I updated the repository. Can you try to compile (or get the snap package, not sure how it works on Linux exactly) and test that?

Thanks
Daniel, CloudCompare admin
spherical
Posts: 3
Joined: Mon Jan 21, 2019 11:11 am

Re: Python, Command Line, EXTRACT_VERTICES to Compute Cloud to Mesh Distance (c2m_dist)

Post by spherical »

Thanks for the quick response.

I reinstalled the snap package (cloudcompare edge 2.10.1) and tried the following command:

Code: Select all

cloudcompare.CloudCompare -SILENT -AUTO_SAVE ON -NO_TIMESTAMP -C_EXPORT_FMT ASC -O /path/to/bone.ply -O /path/to/air.ply -c2m_dist
There's no Unknown or misplaced command: '-EXTRACT_VERTICES' error message, but there is no file /path/to/bone_C2M_DIST.asc being generated, either.

EDIT: I extracted the point cloud myself in the meantime, but it would be preferable if this was done automatically.
spherical
Posts: 3
Joined: Mon Jan 21, 2019 11:11 am

Re: Python, Command Line, EXTRACT_VERTICES to Compute Cloud to Mesh Distance (c2m_dist)

Post by spherical »

I do have another question that I was not able to answer myself the last days.

I now use the following line to compare the point cloud I generated myself to a mesh:

Code: Select all

cloudcompare.CloudCompare -SILENT -AUTO_SAVE ON -NO_TIMESTAMP -C_EXPORT_FMT ASC -O /path/to/air_cloud.xyz -O /path/to/bone.ply -C2M_DIST
This works fine and I can extract the distance values, save them as vertex qualities of the mesh (air.ply), colorize the mesh by the vertex quality (in MeshLab) and obtain a neat 3D visualization of the distances between two surface meshes this way. So far, so good.

But despite the -SILENT option at the beginning of the command, the CloudCompare console window is opened and briefly visible.

Is this expected behavior? For other commands, the -SILENT flag will stop any windows from popping up.
Post Reply