Forum

Author Topic: Iterative Closest Point Algorithm  (Read 18757 times)

jtheule

  • Newbie
  • *
  • Posts: 1
    • View Profile
Iterative Closest Point Algorithm
« on: September 27, 2019, 03:02:17 PM »
Hello,
In my work I often have to export the dense point cloud from Agisoft into CloudCompare to align it with previous lidar datasets using ICP.

I do this because there are no ground control points, only the refence point cloud (Lidar) on the mountain sides.

It is very time consuming.
In CloudCompare, I cut out chunks of permanent features, run alignment. Then I match identifiable points and their coordinates and then make GCP point in Agisoft for better optimization.

It would be nice to have Agisoft to be able to import other point clouds and align selected features for optimization.

I am pretty sure this is not so easy to do, but I thought to had it to a wish list

stephan

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #1 on: October 03, 2019, 03:31:13 PM »
Hi there!

You can import Open3D to the photoscan python envirnomlent and use the ICP algorithm in there to compute the transformations that you need, then apply them directly in photoscan to your chunks.

Cheers,
Stephan

piste

  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #2 on: April 16, 2020, 10:05:39 AM »
Hi Stephan,

have you ever tried that? And does it work?

I am willing to try it myself but I would like to have some feedback from the members of this community.
Even better if someone could share the script but I guess that might be confidential...

Regards,

PolarNick

  • Full Member
  • ***
  • Posts: 102
    • View Profile

Paulo

  • Hero Member
  • *****
  • Posts: 1354
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #4 on: April 30, 2020, 06:16:05 AM »
Hi PolarNick,

i downloaded the script and tried to install the modules open3d and pyhull using:

Code: [Select]
"%programfiles%\Agisoft\Metashape Pro\python\python.exe" -m pip install open3d pyhull
open3d is installed but pyhull installation fails with following error:

Code: [Select]
Building wheels for collected packages: pyhull
  Running setup.py bdist_wheel for pyhull: started
  Running setup.py bdist_wheel for pyhull: finished with status 'error'
  Complete output from command "C:\Program Files\Agisoft\Metashape Pro\python\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\PAUL~1.PEL\\AppData\\Local\\Temp\\pip-build-1_g15vzt\\pyhull\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\PAUL~1.PEL\AppData\Local\Temp\tmpg_10nry1pip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\pyhull
  copying pyhull\convex_hull.py -> build\lib.win-amd64-3.5\pyhull
  copying pyhull\delaunay.py -> build\lib.win-amd64-3.5\pyhull
  copying pyhull\halfspace.py -> build\lib.win-amd64-3.5\pyhull
  copying pyhull\simplex.py -> build\lib.win-amd64-3.5\pyhull
  copying pyhull\voronoi.py -> build\lib.win-amd64-3.5\pyhull
  copying pyhull\__init__.py -> build\lib.win-amd64-3.5\pyhull
  running build_ext
  building 'pyhull._pyhull' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
 
  ----------------------------------------
  Running setup.py clean for pyhull
Failed to build pyhull
Installing collected packages: pyhull, jupyter-core, tornado, pyzmq, jupyter-client
  Running setup.py install for pyhull: started
    Running setup.py install for pyhull: finished with status 'error'
    Complete output from command "C:\Program Files\Agisoft\Metashape Pro\python\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\PAUL~1.PEL\\AppData\\Local\\Temp\\pip-build-1_g15vzt\\pyhull\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\PAUL~1.PEL\AppData\Local\Temp\pip-epjll0cq-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\pyhull
    copying pyhull\convex_hull.py -> build\lib.win-amd64-3.5\pyhull
    copying pyhull\delaunay.py -> build\lib.win-amd64-3.5\pyhull
    copying pyhull\halfspace.py -> build\lib.win-amd64-3.5\pyhull
    copying pyhull\simplex.py -> build\lib.win-amd64-3.5\pyhull
    copying pyhull\voronoi.py -> build\lib.win-amd64-3.5\pyhull
    copying pyhull\__init__.py -> build\lib.win-amd64-3.5\pyhull
    running build_ext
    building 'pyhull._pyhull' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
   
    ----------------------------------------

But I do have Visual Studio Build Tools installed as shown in following screen capture...

What am I missing here?

Help would be welcome!
« Last Edit: April 30, 2020, 06:18:25 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

PolarNick

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #5 on: May 01, 2020, 01:56:30 PM »
Hi Paulo,

1) It seems that "MSVC v140 - VS 2015 C++ Build Tools (v14.00)" should be installed - see attached screenshot (I also downloaded https://visualstudio.microsoft.com/visual-cpp-build-tools/ -> Download Build Tools).

2) Note that after that I encountered another error:

LINK : fatal error LNK1158: cannot run 'rc.exe'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe' failed with exit status 1158

This problem seems to be due to multiple installed versions of Visual Studio :( and w.r.t. https://stackoverflow.com/a/14373113 you should:

2.1) Open C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64
2.2) Copy rc.exe and rcdll.dll to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
2.3) Try pip install pyhull again (worked for me)

3) Note that installation of the open3d led to upgrading some of python packages used in Metashape (jupyter notebook package used for rich python console), and so you will see 'Please wait while Windows configures Agisoft Metashape Professional' (see second screenshot) - after that Metashape will launch and everything will work.

Paulo

  • Hero Member
  • *****
  • Posts: 1354
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #6 on: May 01, 2020, 05:57:38 PM »
Hey PolarNick,

thanks for the recipe. It worked!

And in the VS Build Tools 2019 installation options, I only ticked Windows 10 SDK and MSVC v140....
« Last Edit: May 01, 2020, 06:16:22 PM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

cagritaskin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #7 on: July 05, 2020, 11:19:06 PM »
Hello,

I am trying to use align_model_to_model.py. I managed to install open3d and pyhull. When i run the script i get error: "Importing zmq.backend.cython dailed with zmq.backend.cython.socket.Socket has the wrong size, try recompiling. Expected 72, got 64"

Thanks for any help

cagritaskin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #8 on: July 05, 2020, 11:47:44 PM »
Hi. I installed open3d 0.9.0.0 instead of 0.8.0.0 and problem solved

jnb

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #9 on: February 19, 2021, 01:47:57 AM »
Hello,

I'm trying to use this script on v1.7.1. Thanks to the indications given by PolarNick the installation went fine but when running it I have the following error : AttributeError: module 'open3d' has no attribute 'registration'.

Some research seems to indicate that 'registration' has now moved to 'open3d.pipelines' but my skills in python are to limited to understand more...

Thanks for any help

EDIT : Thank you PolarNick for the updated script, works perfectly now !
« Last Edit: February 20, 2021, 01:07:20 PM by jnb »

antoine billault

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #10 on: February 16, 2022, 07:07:26 AM »
Dear all,
I was wondering if the alignement of the photo was automaticcally update when using that ICP script ?
I mean : if I am aligning a 3D model on a pointcloud, I guess the images (in the chunk containing that 3D model) are directly rotated and translated ?
by an additionnal command in the script ?
should we update the pose of each image ?

thanks for your comments.
antoine

PolarNick

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #11 on: February 16, 2022, 01:32:29 PM »
Script changes only position of model/point cloud.

Maybe switching From and To objects will work for you? (i.e. aligning point cloud on a 3D model instead of aligning 3D model on a point cloud)

Andreas1206

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #12 on: April 18, 2022, 01:37:48 PM »
Hello,

When I run through this script to align an imported scanned mesh to a photogrammetric mesh, everything seems to work fine in the intermediate alignment stages. They show good results (see attached print screen). However, after the final step when the script is finished, the "aligned" mesh is placed somewhere way off in the coordinate system. What could be the reason for this?

I am using the "Coordinate system to bounding box" script before importing the scanned mesh, in order to align the photogrammetric mesh in my local coordinate system - does this transformation maybe somehow interfere with the ICP alignment matrix?

thanks for any advice,
Andreas

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15067
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #13 on: April 18, 2022, 05:45:14 PM »
Hello Andreas,

To analyze the problem we need to reproduce it on our side. Would it be possible to share the following data to support@agisoft.com:
- project file (could be re-saved in PSZ format),
- file to be imported,
- description of the steps that you follow.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Guarouba

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Iterative Closest Point Algorithm
« Reply #14 on: April 20, 2022, 03:22:59 PM »
Hello,

I have the same problem as Andreas1206 when trying to align two point clouds. When visualizing the intermediate steps, everything looks fine. However, after the process, the point cloud disappears in Metashape.  I have sent you the data to reproduce the issue to the email address mentioned above.

Regards,