Forum

Author Topic: Setting the orientation (rotating) the exported 3D point cloud  (Read 6926 times)

raehyuk

  • Newbie
  • *
  • Posts: 12
    • View Profile
Setting the orientation (rotating) the exported 3D point cloud
« on: February 13, 2019, 11:05:58 AM »
Hi,

##Context##
I used PhotoScan for 3D reconstruction from a sequence of spherical images. I exported the reconstructed 3D model as a 3D point cloud (.ply file) and the estimated camera poses (.xml file). I open the 3D point cloud in MeshLab and it is not straight. Part of the reasons is that the 360-degree spherical camera that we used was hand-held (so not straight). In our case, we know the vertical direction of the first image (by manual interaction with an external software), and we can compute a rotation that can map this vertical direction to the up-direction [0,0,1]. (we know the vertical direction *only* of the first image). This vertical direction is a 3D vector u=(ux,uy,uz) in the camera coordinate system (z pointing up).

##Goal##
We would like to apply this rotation (or 3D transformation) to the exported 3D point cloud using Matlab so that the 3D point cloud becomes correctly oriented (should be straight/vertical). We tried several things (we are familiar with 3D points manipulation and 3D transformations) but none of them worked. The problem seems to be in the coordinate systems of the 3D point cloud and/or the spherical cameras. Any tips?


##What we tried##
Let R and T be the rotation and translation of the first image (from the estimated camera poses in the xml file). Let Rup our rotation matrix to straight up the direction.
We tried:
- directly applying Rup (and also its inverse) to the 3D point cloud
- We applied -T (to move the 3D point cloud to the origin) and applied our Rup (and its inverse)
- we also applied R^{-1} then Rup
- we also applied -T, then R^{-1} (so that the first image has its "default" orientation" and at the origin) and then Rup (and also its inverse)
- among other things
However the resulting 3D point cloud is not straight.

Side note: we checked this rotation and it is correct: by applying this rotation to the spherical image, we can obtain a new spherical image (and its equirectangular image) which is straight.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15282
    • View Profile
Re: Setting the orientation (rotating) the exported 3D point cloud
« Reply #1 on: February 13, 2019, 09:54:37 PM »
Hello raehyuk,

Can you share the sample project with only alignment results in PSZ format, so that we could try to modify the chunk's coordinate system according to the first camera orientation?

Were you trying to do that (according to the latter section in your post) in Matlab only or in PhotoScan / Metashape using Python?
Best regards,
Alexey Pasumansky,
Agisoft LLC

raehyuk

  • Newbie
  • *
  • Posts: 12
    • View Profile
Setting the orientation (rotating) the exported 3D point cloud (follow up)
« Reply #2 on: February 18, 2019, 11:15:36 AM »
Hello Alexey,
I asked the question like below

"""
Hi,

##Context##
I used PhotoScan for 3D reconstruction from a sequence of spherical images. I exported the reconstructed 3D model as a 3D point cloud (.ply file) and the estimated camera poses (.xml file). I open the 3D point cloud in MeshLab and it is not straight. Part of the reasons is that the 360-degree spherical camera that we used was hand-held (so not straight). In our case, we know the vertical direction of the first image (by manual interaction with an external software), and we can compute a rotation that can map this vertical direction to the up-direction [0,0,1]. (we know the vertical direction *only* of the first image). This vertical direction is a 3D vector u=(ux,uy,uz) in the camera coordinate system (z pointing up).

##Goal##
We would like to apply this rotation (or 3D transformation) to the exported 3D point cloud using Matlab so that the 3D point cloud becomes correctly oriented (should be straight/vertical). We tried several things (we are familiar with 3D points manipulation and 3D transformations) but none of them worked. The problem seems to be in the coordinate systems of the 3D point cloud and/or the spherical cameras. Any tips?


##What we tried##
Let R and T be the rotation and translation of the first image (from the estimated camera poses in the xml file). Let Rup our rotation matrix to straight up the direction.
We tried:
- directly applying Rup (and also its inverse) to the 3D point cloud
- We applied -T (to move the 3D point cloud to the origin) and applied our Rup (and its inverse)
- we also applied R^{-1} then Rup
- we also applied -T, then R^{-1} (so that the first image has its "default" orientation" and at the origin) and then Rup (and also its inverse)
- among other things
However the resulting 3D point cloud is not straight.

Side note: we checked this rotation and it is correct: by applying this rotation to the spherical image, we can obtain a new spherical image (and its equirectangular image) which is straight.
Modify message
"""

and this is your reply

"""
Hello raehyuk,

Can you share the sample project with only alignment results in PSZ format, so that we could try to modify the chunk's coordinate system according to the first camera orientation?

Were you trying to do that (according to the latter section in your post) in Matlab only or in PhotoScan / Metashape using Python?
"""

Sorry I missed your reply.
I rotate point cloud using matlab and I am using metashape-pro (not python scripting just using gui).
This is link to the .PSZ
https://drive.google.com/file/d/13xxu80auSMp3L0bVpfYvQ9b6OB8oiapF/view?usp=sharing


raehyuk

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Setting the orientation (rotating) the exported 3D point cloud (follow up)
« Reply #3 on: February 18, 2019, 11:22:46 AM »
Also, could you let me know how to change coordinate system?


raehyuk

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Setting the orientation (rotating) the exported 3D point cloud
« Reply #4 on: February 18, 2019, 01:52:29 PM »
Sorry alexey,

I am using photoscan-pro and matlab for rotating point cloud.

Here is my project in .PSZ
Link to google drive.

https://drive.google.com/file/d/13xxu80auSMp3L0bVpfYvQ9b6OB8oiapF/view?usp=sharing

I was not able to upload it in attachment because the file is too big.

Ashlie38

  • Guest
Re: Setting the orientation (rotating) the exported 3D point cloud
« Reply #5 on: April 26, 2019, 03:13:11 PM »
Three is a small mount of points which are far away from the main points cloud. This situation can be caused by wrong matched points in the stage of ba or dense matching tutuapp.
« Last Edit: April 29, 2019, 12:18:12 PM by Ashlie38 »