Forum

Author Topic: align_model_to_model gives bad allocation memory error  (Read 7886 times)

Paulo

  • Hero Member
  • *****
  • Posts: 1629
    • View Profile
align_model_to_model gives bad allocation memory error
« on: April 22, 2025, 01:51:00 AM »
Hello all,

i am trying 2 points clouds. One photogrammetric with 151 Millon points and an imported Laser scan with 71 Millon points.

It runs doing first coarse ICP registration and then fine, onlly to exit with Memory error.
Code: [Select]
2025-04-21 16:27:29 Script started...
2025-04-21 16:27:29 Aligning 20250223_094629_2 (71867858 points) to Dense Cloud (151534058 points)...
2025-04-21 16:27:29 ExportPointCloud: path = C:\Users\Admin\AppData\Local\Temp\tmp8jzgwfwo, save_point_color = off, save_point_normal = off, save_point_classification = off, save_point_confidence = off, save_comment = off, format = PointCloudFormatPLY
2025-04-21 16:27:30 point cloud size: 151534058 points
2025-04-21 16:27:30 Saving point cloud...
2025-04-21 16:27:43 saved 151534058 points
2025-04-21 16:27:43 Finished processing in 13.895 sec (exit code 1)
2025-04-21 16:27:44 ExportPointCloud: path = C:\Users\Admin\AppData\Local\Temp\tmpolwge6in, save_point_color = off, save_point_normal = off, save_point_classification = off, save_point_confidence = off, save_comment = off, format = PointCloudFormatPLY
2025-04-21 16:27:44 Saving point cloud...
2025-04-21 16:27:44 point cloud size: 71867858 points
2025-04-21 16:27:58 saved 71867858 points
2025-04-21 16:27:58 Finished processing in 14.724 sec (exit code 1)
2025-04-21 16:27:59 Vertices number: 71867858, 151534058
2025-04-21 16:28:02 scale_ratio=1.0 target_resolution=0.1
2025-04-21 16:28:02 1/2: Coarse ICP registration...
2025-04-21 16:30:31     estimated in 148.57497239112854 s
2025-04-21 16:30:31 2/2: Fine ICP registration...
2025-04-21 16:34:50 Traceback (most recent call last):
2025-04-21 16:34:50   File "C:/Users/Admin/Downloads/align_model_to_model.py", line 562, in align
2025-04-21 16:34:50     M12 = align_two_point_clouds(v1, v2, scale_ratio, target_resolution, no_global_alignment, preview_intermidiate_alignment)
2025-04-21 16:34:50   File "C:/Users/Admin/Downloads/align_model_to_model.py", line 198, in align_two_point_clouds
2025-04-21 16:34:50     icp_result2 = icp_registration(to_point_cloud(v1), to_point_cloud(v2), voxel_size=icp_voxel_size2, transform_init=transformation, max_iterations=100)
2025-04-21 16:34:50   File "C:/Users/Admin/Downloads/align_model_to_model.py", line 305, in icp_registration
2025-04-21 16:34:50     reg_p2p = o3d_registration.registration_icp(
2025-04-21 16:34:50 MemoryError: bad allocation

Any help will be appreciated...

Update1. I cropped my photogrammetric point cloud to laser  scan extents (point count down from 151 Millon to 112 Millon) and reran the process...

It ran to ICP  coarse registration and is continuing without responding for almost 2 hours without completing...Metashape keeps using CPU and Memory...see attachment

Is it normal?

Update 2. After more than 3 hours, it finally completed fine ICP registration but with hugw shift between laser scan and point cloud... see 2nd attachment...

In this case the script is not giving good results... :(
« Last Edit: April 22, 2025, 05:28:01 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

Paulo

  • Hero Member
  • *****
  • Posts: 1629
    • View Profile
Re: align_model_to_model gives bad allocation memory error
« Reply #1 on: April 22, 2025, 08:04:55 PM »
I did another registration test on reduced point cloud and laserscan (4.6 to 4.9 Millon points), without using  Initial Alignment.

The result follows:
Code: [Select]
2025-04-22 10:43:48 Script started...
2025-04-22 10:43:48 Aligning Copy of 20250223_094629_2 (4626992 points) to Dense Cloud (4967505 points)...
2025-04-22 10:43:48 ExportPointCloud: path = C:\Users\Admin\AppData\Local\Temp\tmp128pl80b, save_point_color = off, save_point_normal = off, save_point_classification = off, save_point_confidence = off, save_comment = off, format = PointCloudFormatPLY
2025-04-22 10:43:48 Saving point cloud...
2025-04-22 10:43:48 point cloud size: 4967505 points
2025-04-22 10:43:49 saved 4967505 points
2025-04-22 10:43:49 Finished processing in 1.301 sec (exit code 1)
2025-04-22 10:43:49 ExportPointCloud: path = C:\Users\Admin\AppData\Local\Temp\tmp2_2dhgko, save_point_color = off, save_point_normal = off, save_point_classification = off, save_point_confidence = off, save_comment = off, format = PointCloudFormatPLY
2025-04-22 10:43:49 point cloud size: 4626992 points
2025-04-22 10:43:49 Saving point cloud...
2025-04-22 10:43:51 saved 4626992 points
2025-04-22 10:43:51 Finished processing in 1.65 sec (exit code 1)
2025-04-22 10:43:51 Vertices number: 4626992, 4967505
2025-04-22 10:43:51 Warning! No target resolution!
2025-04-22 10:43:51 It will be estimated based on rough average distance between points!
2025-04-22 10:43:57     target_resolution=0.038714186192398484 (resolution1=0.038714186192398484, resolution2=0.0381127038753045)
2025-04-22 10:43:57     estimated in 6.623565435409546 s
2025-04-22 10:43:57 scale_ratio=1.0 target_resolution=0.038714186192398484
2025-04-22 10:43:57 1/3: Global registration...
2025-04-22 10:44:07     estimated in 9.135238409042358 s
2025-04-22 10:44:07 1/3: Global registration shown!
2025-04-22 10:44:20 2/3: Coarse ICP registration...
2025-04-22 10:44:28     estimated in 8.306766033172607 s
2025-04-22 10:44:28 2/3: Coarse ICP registration shown!
2025-04-22 10:44:38 3/3: Fine ICP registration...
2025-04-22 10:47:19     estimated in 160.92785954475403 s
2025-04-22 10:47:19 3/3: Fine ICP registration shown!
2025-04-22 10:47:43 Estimated transformation matrix:
2025-04-22 10:47:43 Matrix([[0.9999892656729132, 0.00462328948060216, 0.00030615911561845147, 1544.0878632638232],
2025-04-22 10:47:43        [-0.00462327653635722, 0.9999893116765609, -4.2973719519968275e-05, 78.36259814453359],
2025-04-22 10:47:43        [-0.0003063545232361975, 4.1557799970464134e-05, 0.9999999522099525, -17.21094006630267],
2025-04-22 10:47:43        [0.0, 0.0, 0.0, 1.0]])
2025-04-22 10:47:43 Script finished!
Registration in Z is good but still a close to 8 m offset in XY!
« Last Edit: April 22, 2025, 08:06:43 PM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15729
    • View Profile
Re: align_model_to_model gives bad allocation memory error
« Reply #2 on: April 23, 2025, 02:02:50 PM »
Hello Paul,

Can you please share the project and point clouds where you have observed the large alignment issue when using the script?

If possible, please also share the original detailed point cloud for testing.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1629
    • View Profile
Re: align_model_to_model gives bad allocation memory error
« Reply #3 on: April 23, 2025, 05:10:49 PM »
Thank you Alexey,

will share thru OneDrive...

Project with reduced photo point cloud and laser. Also the original external laser file..
Best Regards,
Paul Pelletier,
Surveyor