Forum

Author Topic: Metashape 2.0 Laser Scan Referencing  (Read 1042 times)

mitchgalea

  • Newbie
  • *
  • Posts: 16
    • View Profile
Metashape 2.0 Laser Scan Referencing
« on: February 21, 2023, 02:32:49 AM »
Hello,

I am using Metashape 2.0 Terrestrial laser scans feature to align TLS scans captured with the Leica RTC360, with images captured from other sources. I have followed the procedure listed here https://agisoft.freshdesk.com/support/solutions/articles/31000168474-terrestrial-laser-scans-processing-in-metashape-2-0-0 . It works and I can align the TLS scans with the images. My issue though is the position of the laser scans after alignment is different, this makes sense because we reset alignment, but is there a way to add the reference information to the laser scans so that after alignment the laser scans keep the initial position. I have tried adding reference information to the laser scan images based on the initial position, but this doesn't do anything (seems that images attached to laser scans are ignored when it comes to reference).

Any help would be appreciated

mitchgalea

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Metashape 2.0 Laser Scan Referencing
« Reply #1 on: February 21, 2023, 08:12:16 AM »
I figured out how to fix this. I had to compute the chunk transform that would ensure that the laser scans are in the correct position. To do this prior to alignment I duplicated the chunk, and then aligned the original chunk. From there I had to use the python console.

Code: [Select]
# gets chunks to use
non_aligned_chunk = Metashape.app.document.chunks[1]
aligned_chunk = Metashape.app.document.chunks[0]

# function to get camera based on label
def get_camera(chunk,label):
    for camera in chunk.cameras:
        if camera.label == label:
            return camera
    return None

# gets a spherical from a laser scan for both chunks
non_aligned_camera = get_camera(non_aligned_chunk, "Scan_001")
aligned_camera = get_camera(aligned_chunk, "Scan_001")

# non aligned camera is in the correct position so we work out chunk transform to equal non aligned camera position
aligned_chunk.transform.matrix = non_aligned_camera.transform * aligned_camera.transform.inv()

bassistas

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Metashape 2.0 Laser Scan Referencing
« Reply #2 on: April 11, 2023, 07:16:59 AM »
I figured out how to fix this. I had to compute the chunk transform that would ensure that the laser scans are in the correct position. To do this prior to alignment I duplicated the chunk, and then aligned the original chunk. From there I had to use the python console.

Code: [Select]
# gets chunks to use
non_aligned_chunk = Metashape.app.document.chunks[1]
aligned_chunk = Metashape.app.document.chunks[0]

# function to get camera based on label
def get_camera(chunk,label):
    for camera in chunk.cameras:
        if camera.label == label:
            return camera
    return None

# gets a spherical from a laser scan for both chunks
non_aligned_camera = get_camera(non_aligned_chunk, "Scan_001")
aligned_camera = get_camera(aligned_chunk, "Scan_001")

# non aligned camera is in the correct position so we work out chunk transform to equal non aligned camera position
aligned_chunk.transform.matrix = non_aligned_camera.transform * aligned_camera.transform.inv()

Can you please give me some more details on how you managed to do this? I duplicated the chunk, I aligned them using markers and then I tried to run your script but I get this error: 'NoneType' object has no attribut 'transform'

mitchgalea

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Metashape 2.0 Laser Scan Referencing
« Reply #3 on: May 07, 2023, 04:03:03 AM »
Hello,

Not too sure about the issue you are facing. It seems that the function get_camera is returning None for either non_aligned_camera or aligned_camera. Please ensure that the label is correct, ie in my example I was using "Scan_001", that is the name of the scan image.