Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Transformation Globally and save as PCD #1979

Open
christianbussmann opened this issue Mar 8, 2024 · 12 comments
Open

Apply Transformation Globally and save as PCD #1979

christianbussmann opened this issue Mar 8, 2024 · 12 comments
Labels

Comments

@christianbussmann
Copy link

Describe the bug
If I use the "Apply to global coordinates" feature in the transform dialoge (in Axis, Angle) it seems like it is still not applied globally, but instead still changes something different.
If I then save the result as a .pcd the result is identical, no matter if I enable or disable this option.
Also: If I save the cloud as .txt and reload it, and then save as new .pcd the result is different.

How to reproduce

  1. Load a .pcd file
  2. Ctrl+T
  3. Click on Axis, Angle
  4. Enter Tknow transformation you like
  5. do not active "Apply to global coordinates"
  6. save the resulting cloud as A.pcd
  7. Load the same input file as before (untransformed one)
  8. enter the same transformation as before
  9. but now activate the option "Apply to global coordinates"
  10. save as B.pcd
  11. compare A.pcd and B.pcd

Both PCDs are now the same, but they shouldn't be. Also: The resulting .pcd is always different than one saved with CC Version 2.12.X or 2.9.1, no matter if I enable or disable the option.

Expected behaviour
If that option is now there: (why is it needed anyways?)

  • when "Apply global" is activated and you save the .pcd. The positions of the raw points should change.

Additional context
Workaround:
When you transform, but then save e.g. as .csv/.txt, then import again and save as .pcd the Problem is not occuring.

Your environment

  • CC Version 2.13.0
  • OS & Version: Windows 10
  • Graphics card: Intel Iris Xe
  • Qt Version (if compiling): -
@christianbussmann christianbussmann changed the title Apply Transformation Globally Apply Transformation Globally and save as PCD Mar 8, 2024
@HeadLessHUN
Copy link
Collaborator

HeadLessHUN commented Mar 8, 2024

I think you are misunderstanding something.
"Apply to global coordinates" just means that it will use global shift during the transformation. But unless you drop the applied global shift then global coordinates will be written to pcd file and any other formats.

both of your method should result in the same cloud, except if the transformation larger than 10^4. because if it is larger it could corrupt your points which was not applied to global.

The only cause to have that option is to prevent users to loss their point's precision because of big transformations.

see typical precision loss:
image

what you really want to achieve?

@christianbussmann
Copy link
Author

christianbussmann commented Mar 8, 2024

Ok I then I might have to refrase something here:
When I do the same in an older CLoud Compare Version (eg. 2.12.0 or 2.9.1) the saved pcd file is different when I apply the same transformation operation in the new version (2.13.0) to the same input cloud (no matter what I do with the apply global option)
Meaning: The actual point position is changed in older versions by the transformation, but not (or differently) in > 2.13.0.

@christianbussmann
Copy link
Author

For example I did a rotation of the pointcloud by 1.5 deg in Rx and saved the resulting point cloud as pcd.
I did that in both versions.
The resulting pcd is completely different

@dgirardeau
Copy link
Member

dgirardeau commented Mar 9, 2024

Ok, so I took the time to look at the issue this week-end, and here are my observations:

  • @christianbussmann is correct is his assumptions, applying a transformation to the Global coordinate system can change the local coordinates if there's a rotation and a non-zero Global Shift (as the origin is different), or simply if the Global Shift & Scale information needs to be updated
  • there was no problem with the maths
  • but there were 2 issues: first, the PCD files were not saving the Global Shift information if no sensor was associated to the cloud 😅. Second, if the applied transformation was resulting in too large coordinates, and the user was refusing to change the Global Shift & Scale information, then the resulting cloud could have no Global Shift & Scale information...

So there were 2 potential reasons why the PCD files were the same (but mostly because the Global Shift & Scale information was dropped...).

Can you retry with the 2.13.1.preview version here: https://www.cloudcompare.org/release/CloudCompare_v2.13.1.preview_setup_x64.exe

@HeadLessHUN
Copy link
Collaborator

I also looked at it, and found out something was strange, that is why i did not react to the last message. (related to global shift was not stored or stored somewhat badly)

open a cloud,apply large transofrmation, save as pcd rearead transformed pcd, and the two were different. about a half a meter difference.

seems to be fixed with the preview.

@christianbussmann
Copy link
Author

Hi Guys, thank you for the fast answers :)

Sadly I still have some issues I don't quite understand.

I show you in pics what I mean:
If I open up a .pcd in Cloud Compare 2.9.1 and rotate that point cloud by some degree in one axsis (green before rotation, red after rotation)
grafik

Then save the .pcd of the rotated version in a new pcd.

If I open that new pcd in CC.2.9.1 it is where I expect it to be. But when I open it up in CC 2.13.1_preview it is somwhere else totally different:
grafik

How can that be? Also vice versa:
If I open the input cloud in 2.13.1_preview, rotate and then save the pcd and then open it up iin 2.9.1 the rotated version of the point cloud is shown at the exact position as the unrotated one!! (they should be a bit apart from eachother as seen in the first pic).

ALso: If I use my own written loader to load the pcd. The positions generated from 2.9.1 are as expected but the ones from 2.13.1_preview are at least weird and not anywhere expected.

Did I do something wrong? :/

@dgirardeau
Copy link
Member

Can you share your PCD file with us? (or you can send it to admin@cloudcompare.org)

Something that was not managed in the old versions is the concept of sensors. This is now the case. That's the only difference I see (well, apart that the first support of PCD files was done manually, by Luca Penasa, and we have now transitioned to using the real PCL library to import and export PCD files).

@dgirardeau
Copy link
Member

Also, for the example above, are you applying the rotation to the local or to the global coordinate system (it only makes sense if you have a Global Shift defined)

@christianbussmann
Copy link
Author

christianbussmann commented Mar 11, 2024

You got mail ;) I described again what transformation I did in CC.
To your question above: How do I do that? By activating apply to global?
If yes: I just did that, didn't change anything in my results.

@christianbussmann
Copy link
Author

I always get an email delivery error when I try to sent it to the mail you mentioned, here you go:
CC_tests.zip

cut.pcd is the original one (unrotated, just cut from some data in CC.2.9.1 and saved again)

cut_rotated_saved_2.13.1_preview.pcd is the one loaded, rotated and saved again in CC2.13.1_preview

cut_rotated_saved_2.9.1.pcd ist the one loaded, rotated and saved in CC.2.9.1.

The rotation I did was:

I marked the cloud,
Pressed CTRL+T,
Axis, Anlge,
Rotation Axis X: 1.0, Y:0, Z:0,
Rotation angle (degrees)
1.5000 deg.
Translation 0,0,0, scale 1.0
No options.

@dgirardeau
Copy link
Member

Ok, so if you rotate the PCD file with 2.13.1, save it, and reopen it with 2.13.1, it works.

I didn't pay attention to the fact that you were rotating in version 2.9 (which is more than 6 years old 😅). As I said, this version was probably not using the PCL library to save the PCD file, and it was ignoring the 'sensor' when applying the transformation.

@dgirardeau
Copy link
Member

You could try to remove the sensor below the cloud in v2.9 before saving the PCD file, that should help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants