Forum

Author Topic: Diffeent camera positions - headless vs. interactive  (Read 665 times)

michael.baltazar

  • Newbie
  • *
  • Posts: 2
    • View Profile
Diffeent camera positions - headless vs. interactive
« on: April 30, 2024, 02:26:24 AM »
Hi - one of our developers is running into an issue with Metashape with different results in coming positions occurring between interactive mode and headless mode.  Here's the details from him:

I am encountering an issue where importing laser scans (6 cameras from a single .e57 file) using the python API, so with a headless Metashape 2.1.1. It will mess up the positions of the cameras, except for the first one. This will not happen if I import the same file manually in Metashape or if I run the same script in Metashape, the issue is only with the command lines.

The first camera of the laser scan file will always have the correct position but not the following ones. 

I also tried to import cameras one by one (from 6 different files instead of 1) and the issue was the same but I found a temporary workaround: if I import all the cameras in separate chunks and then merge the chunks together, they will all have the desired position.

Here is an example:

The chunk1-wrong chunkwas created using the following script :

Code: [Select]
import Metashape
doc = Metashape.Document()
chunk = doc.addChunk()
laser_scan_path = "my/e57/path"
chunk.importPointCloud(path=laser_scan_path, format=Metashape.PointCloudFormatE57, is_laser_scan=True)
doc.save(path=str(output_project_file), chunks=[chunk])

(image 1)

Positions are not correct.

If, in the same file or another one, I create another chunk, chunk1-good, and I run the exact same commands (the chunk.importPointCloud part), or if I simply import the laser scans from the menu, the positions will be correct :

(image 2)

I did some tests with another data set and also tried to change some arguments of importCloudPoint, like precision and scanner_at_origin but it didn't change the results.

Versions are the same : 2.1.1 but build are different, 17821 versus 17803.

I would very much appreciate some help please.

Thank you!


« Last Edit: April 30, 2024, 06:00:31 AM by michael.baltazar »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Diffeent camera positions - headless vs. interactive
« Reply #1 on: May 07, 2024, 03:17:36 PM »
Hello Michael,

Is it possible to share the script that imports six laser scans in headless mode which results in "wrong" results?
Best regards,
Alexey Pasumansky,
Agisoft LLC

maxg92

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Diffeent camera positions - headless vs. interactive
« Reply #2 on: May 07, 2024, 09:45:34 PM »
HI Alexey,

Thanks for your answer!

EDIT : I just found a solution, looks like it's working if I save the file in .psx instead of .psz



The script is as simple as this :

Code: [Select]
import Metashape

laser_scans_path = "S:/temp/laserscans-withmarkers.e57"
output_path = "S:/temp/import_lidar_test_001.psz"

doc = Metashape.Document()
chunk = doc.addChunk()

chunk.importPointCloud(
path=laser_scans_path,
format=Metashape.PointCloudFormatE57,
is_laser_scan=True
)

doc.save(path=output_path)

It is run within a Python 3.9  shell environment where Metashape-2.1.1 was installed. So /path/to/Python39/python.exe import_laser_scans.py.
I also tried to run the script using metashape.exe but the results were the same.
"C:/Program Files/Agisoft/Metashape Pro/metashape.exe" -r import_laser_scans.py

Couple things I tried :
- Looked into the coordinate system by forcing it to the following, but everything looked good there.
Code: [Select]
crs = Metashape.CoordinateSystem('LOCAL_CS["Local Coordinates (m)",LOCAL_DATUM["Local Datum",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]')
- Looked into some parameters, like scanner_at_origin but it didn't change anything.


The 6 laser scans are still being imported, just the position of their cameras is wrong (except, always for the first one of the file). As you can see on the joined image, the alignment is good but the cameras are underground.

I hope we can resolve this, thanks again!
Max
« Last Edit: May 08, 2024, 12:29:13 AM by maxg92 »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Diffeent camera positions - headless vs. interactive
« Reply #3 on: May 08, 2024, 02:24:03 PM »
Hello Max,

So the problem only persists, if the project is saved in PSZ format after using the import script?
Best regards,
Alexey Pasumansky,
Agisoft LLC

maxg92

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Diffeent camera positions - headless vs. interactive
« Reply #4 on: May 08, 2024, 07:36:07 PM »
Hi Alexey,

Yes, exactly.
I think that even if you already have laser scans imported, if you save your file in .psz it's gonna change the position.
Because I had tried to import manually using the GUI, and then via python I was just duplicating the chunk and saving again, and the position was different.

For now, I changed my workflow to save a .psx instead.

Thanks!
Max