Calculations in the CLI

Feel free to ask any question here
Post Reply
mm_max_cloud
Posts: 3
Joined: Fri Feb 16, 2024 11:39 am

Calculations in the CLI

Post by mm_max_cloud »

I am trying to substract a plane from my point cloud and only keep the points above a certain distance.
My CLI script works fine except for the filtering of the scalar field.
Is it possible to perform calculations on the defined variables "MAX"; "MIN"; "SAT_MAX";"DISP_MIN" etc.?
I keep getting this error message:
Screenshot 2024-02-16 125042.png
Screenshot 2024-02-16 125042.png (43.35 KiB) Viewed 3533 times
My shell script for the filtering of the SF is as follows:

Code: Select all

-FILTER_SF ($MAX)*0.99 MAX
any help is highly appreciated :)
daniel
Site Admin
Posts: 7721
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Calculations in the CLI

Post by daniel »

Which version are you using? Only version 2.13 supports this.
Daniel, CloudCompare admin
mm_max_cloud
Posts: 3
Joined: Fri Feb 16, 2024 11:39 am

Re: Calculations in the CLI

Post by mm_max_cloud »

I am using CloudCompare 2.13beta
daniel
Site Admin
Posts: 7721
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Calculations in the CLI

Post by daniel »

That's maybe an old beta version. The 2.13 official version has been released last week, you should try it.
Daniel, CloudCompare admin
HeadLess
Posts: 56
Joined: Mon Mar 25, 2019 9:27 pm

Re: Calculations in the CLI

Post by HeadLess »

your $MAX value was not properly converted by your shell, probably because using single quotes, or escaping or because of the brackets. make sure that your command sends proper commands to CC. you could try to send your commands to a file, then load that with

-COMMAND_FILE {file}
command, that way you can check everything in your file.

But to be sure Daniel CC supports arithmetic during filter SF? does it really need to in this case?

if you use bash to calculate your min value $(($MAX*0.99)) that way your bash will calculate your value.
mm_max_cloud
Posts: 3
Joined: Fri Feb 16, 2024 11:39 am

Re: Calculations in the CLI

Post by mm_max_cloud »

Thank you for your suggestions.
I installed the 2.13 stable version of cloud compare - but still get the same error.

I think the problem is that the "-FILTER_SF" command does not support arithmetic operations.
It is not possible to access the "MAX" variable and perform calculations on it.

From my understanding the "MAX" variable is a CloudCompare internal variable, that cannot be converted to a system variable to perform calculations on.

Is there a workaround to set the "MAX" and "MIN" values adaptively (e.g. always from 95% to 100%)?
daniel
Site Admin
Posts: 7721
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Calculations in the CLI

Post by daniel »

CloudCompare does understand 'MAX' (it's in its code). The issue here is really that your batch process is not replacing "$MAX*0.99" by a numerical value.

CloudCompare literally receives "$MAX*0.99" instead of a numerical value (hence the error message).
Daniel, CloudCompare admin
HeadLess
Posts: 56
Joined: Mon Mar 25, 2019 9:27 pm

Re: Calculations in the CLI

Post by HeadLess »

I looked at it yesterday.
-FILTER_SF only accept doubles or exactly MIN or MAX string. so computation is not possible.

Then i was looking for a workaround but SF_OP does not accept MIN/MAX as values

i was trying to do a normalized SF so you can just drop points below a known number. But that is still not possible. but this is i think the easiest to implement in CC.

something like this, -SF_OP 0 DIV MAX -FILTER_SF 0.95 MAX this could work i think with minimal changes in CC.
HeadLess
Posts: 56
Joined: Mon Mar 25, 2019 9:27 pm

Re: Calculations in the CLI

Post by HeadLess »

I created a quick PR to make this possible so the given command_file would work, if it gets merged as is.
https://github.com/CloudCompare/CloudCompare/pull/1967

Code: Select all

-NO_TIMESTAMP
-AUTO_SAVE OFF
-O "cloud_with_sf"
-SF_OP 0 DIV MAX -NOT_IN_PLACE
-FILTER_SF 0.95 1
-RENAME_ENTITIES "filtered"
-SAVE_CLOUDS
Post Reply