Compute normals using command line

Feel free to ask any question here
manolo-
Posts: 6
Joined: Tue Mar 28, 2017 3:11 pm

Compute normals using command line

Post 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 :)
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Compute normals using command line

Post 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 ;)
Daniel, CloudCompare admin
manolo-
Posts: 6
Joined: Tue Mar 28, 2017 3:11 pm

Re: Compute normals using command line

Post 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 !
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Compute normals using command line

Post 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.
Daniel, CloudCompare admin
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Compute normals using command line

Post by daniel »

Why are you using 3DReshaper by the way?
Daniel, CloudCompare admin
manolo-
Posts: 6
Joined: Tue Mar 28, 2017 3:11 pm

Re: Compute normals using command line

Post 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^^)
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Compute normals using command line

Post 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).
Daniel, CloudCompare admin
manolo-
Posts: 6
Joined: Tue Mar 28, 2017 3:11 pm

Re: Compute normals using command line

Post by manolo- »

Yep of course it would be better to only use one software :)
manolo-
Posts: 6
Joined: Tue Mar 28, 2017 3:11 pm

Re: Compute normals using command line

Post 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!
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Compute normals using command line

Post 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 ;).
Daniel, CloudCompare admin
Post Reply