Forum

Author Topic: "Tie Points/Build Point Cloud..." via Python API?  (Read 10620 times)

Jedidiah Mitchell

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Aura FX Studios
"Tie Points/Build Point Cloud..." via Python API?
« on: November 03, 2021, 11:10:41 PM »
I'm trying to build a script to auto-mesh laser scan data but I'm stuck on generating tie points and can't figure out what that menu command is doing behind the scenes.

Our manual workflow is to import scans (structured e57s), align via the Agisoft quick_layout.py script, use Tools --> Tie Points --> Build Point Cloud... to generate tie points, adjust the region as needed then build the mesh.

In the current (1.7.5) Python reference manual there is no equivalent I can find to that menu command. When I use it from the UI the console echoes:

Code: [Select]
BuildPoints: accuracy = High, preselection = generic, reference, keypoint limit = 40000, keypoint limit per mpx = 1000, tiepoint limit = 12000, apply masks = 0, filter tie points = 1, filter stationary points = 1, guided matching = 0
but there is no Chunk.buildPoints() or similar method in the manual.

Comparing the arguments, I suspected this was actually a wrapper of Chunk.matchPhotos(), and that does generate tie points but while the UI command gets a result of, for example, "132 of 158" points in the tie points info panel, the matchPhotos() method returns "0 of 158" and doesn't populate a point cloud, which prohibits building the mesh.

Am I missing a step that needs to happen after running matchPhotos() or is this entirely the wrong method to use?

Thanks!

Paulo

  • Hero Member
  • *****
  • Posts: 1595
    • View Profile
Re: "Tie Points/Build Point Cloud..." via Python API?
« Reply #1 on: November 04, 2021, 01:39:44 AM »
Hello jed,

I think you should use  chunk.triangulatePoints() after chunk.matchPhotos()

It should work,
Best Regards,
Paul Pelletier,
Surveyor

Jedidiah Mitchell

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Aura FX Studios
Re: "Tie Points/Build Point Cloud..." via Python API?
« Reply #2 on: November 04, 2021, 03:23:12 AM »
That was it, thanks Paulo!

I have a related question, in case you know the answer --

Using Chunk.buildModel() works and in a few tests the meshes look as expected but it's missing some arguments that are represented in the UI, like setting the Quality and Depth Filtering.

I have seen what I think are those arguments in the Chunk.buildDepthMaps() method (downscale and filter_mode?) -- does that mean when a mesh is being built via the UI there is something else going on?

Reading the progress log the biggest difference I see is that the UI version seems like it is prepared to generate new depth maps but it doesn't actually do so when starting with laser scans. Is that correct?

The console echoes are also different, with more of the feedback I expect in the UI version:

From a python command:
Code: [Select]
BuildModel: source data = Depth maps, surface type = Arbitrary, face count = 60000000, volumetric masking = 0, OOC version, interpolation = Enabled, vertex colors = 0
From the UI:
Code: [Select]
BuildModel: quality = High, depth filtering = Moderate, PM version, source data = Depth maps, surface type = Arbitrary, face count = 60000000, volumetric masking = 0, OOC version, interpolation = Enabled, vertex colors = 0

Something I would love to see in future versions of Metashape is the option to echo UI commands as Python calls for debugging / learning.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15673
    • View Profile
Re: "Tie Points/Build Point Cloud..." via Python API?
« Reply #3 on: November 04, 2021, 12:37:01 PM »
Hello jedmitchell,

Depending on the source data used for the Build Model procedure you need either to generate the depth maps via buildDepthMaps command, or to generate a dense point cloud via buildDenseCloud command.

So in you case you need to use chunk.buildDepthMaps(downscale = 2, filter_mode = Metashape.MildFiltering, reuse_depth=False)
then call chunk.buildModel(surface_type = Metashape.Arbitrary, interpolation = Metashape.EnabledInterpolation, face_count = Metashape.CustomFaceCount, face_count_custom = 60000000, source_data = Metashape.DepthMapsData, vertex_colors = False, keep_depth = True)

If you are working with the laser scan data only, then you can skip the depth maps generation stage, as the depth information is already embed to the imported TLS cameras.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Jedidiah Mitchell

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Aura FX Studios
Re: "Tie Points/Build Point Cloud..." via Python API?
« Reply #4 on: November 04, 2021, 06:34:49 PM »
Thanks Alexey -- that all matches about what we had guessed based on testing but thanks for confirming it and providing the sample code.