Page 1 of 2

Compute normals using command line

Posted: Tue Mar 28, 2017 3:31 pm
by manolo-
Hello,

I have a lot of point clouds in format .LAS

What I'd like to do is to create a batch file which will automatize the "compute normals" process and save the point clouds files in the format .PLY

Here is the code of the batch I've written: (it gives me another ply file in output however without any normals)

Code: Select all

"C:\Program Files\CloudCompare\CloudCompare.exe" -AUTO_SAVE OFF -COMPUTE_NORMALS -O E1.las -C_EXPORT_FMT PLY -SAVE_CLOUDS 
So I've tried this code: (but here I get an error message: "Failed to orient the normals of Cloud 'E1 - Cloud'!")

Code: Select all

"C:\Program Files\CloudCompare\CloudCompare.exe" -AUTO_SAVE OFF -COMPUTE_NORMALS -O E1.las -ORIENT_NORMS_MST 6 -C_EXPORT_FMT PLY -SAVE_CLOUDS



Does anyone have any idea how to make it work ?

Thank you very much :)

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 7:08 am
by daniel
Yes, it's a bit misleading but the 'COMPUTE_NORMALS' option can only be used with gridded scans (FARO, DP, PTX, etc.). It's a very simple algorithm to compute normals based on the grid structure. It cannot be used to compute normals on any point cloud.

It would be possible to add the generic algorithm to the command line... but someone needs to do it ;)

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 7:25 am
by manolo-
Thank you for your answer Daniel.

My point clouds are acquired from photogrammetric methods (using PhotoScan).
First of all I get the first half of the object. (.ply with normals computed in PhotoScan)
Then, i get the other side of the object (again, .ply with normals computed in PhotoScan)
The third step is to put the 2 point clouds together to have the final point cloud of the whole object (I use 3DReshaper, but I can only save the point cloud in the following formats: asc, csv, nsd, pts, ptx, las, igs. Which means i loose the normals...)

That's the reason why I wanted to use CloudCompare to compute them again ^^

So if I understand what you said, I won't be able to use the command COMPUTE_NORMALS in my case.

Where can I get the generic algorithm ? I could try something.

Thank you !

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 8:41 am
by daniel
The 'generic algorithm' is the one you use when using 'Edit > Normals > Compute'. See how it is actually called in the code in 'ccEntityAction::computeNormals' (ccEntityAction.cpp). There's a lot of code here because it handles all cases (clouds, meshes, with or without gridded structure, etc.) as well as the display.

In fact for clouds it's simply the 'ccPointCloud::computeNormalsWithOctree' method that should be called. And you don't need to take care of the display in command line mode.

There are just several parameters that may be passed through the command line... You can maybe look at other command line options such as 'CommandRoughness' (in ccCommandLineCommands.h) for the simplest, or 'CommandRasterize' (in ccCommandRasterize.h) for more complex ones with options.

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 9:42 am
by daniel
Why are you using 3DReshaper by the way?

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 11:16 am
by manolo-
I'm using 3DReshaper to align the 2 clouds together. (If find it easier and faster to use + there is a function 'Best Fit' which seems to work very well^^)

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 11:23 am
by daniel
well, in the end the process may be faster if you stay in CloudCompare ;) (we also have a best fit registration tool, and you wouldn't have to recompute the normals).

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 11:28 am
by manolo-
Yep of course it would be better to only use one software :)

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 12:43 pm
by manolo-
I guess I've found the code your were speaking about (ccPointCloud::computeNormalsWithOctree): https://github.com/CloudCompare/CloudCo ... intCloud.h

But I don't really know how to exploit it...

Do you think I could write a batch file or a Python script calling this *.h file ? Or this doesn't work this way ?!

(I don't want to be asked the different parameters, I think I already know what they will be: Triangulation + check orientation + minimum spanning tree knn = 15.)


Thank's in advance!

Re: Compute normals using command line

Posted: Wed Mar 29, 2017 2:46 pm
by daniel
Oh no, I pointed you to this method if you wanted to add a new 'Command' to CC's code (you would have to actually code it and compile CC). But it's not that hard if you know how to develop in C++ (or if you know someone who can do it ;).