Forum

Author Topic: Recalculate marker projections programmatically  (Read 1665 times)

colin.spexigeo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Recalculate marker projections programmatically
« on: May 16, 2019, 10:38:18 PM »
Hi there,

We are trying to add some interactivity to our GCP automation process, allowing the user to adjust the marker projections in photos in an outside program. We then want to load up those specific adjustments into Metashape and have Metashape do the marker re-projection on unpinned marker projections.

I'm able to set the `pinned` and `coords` via Python just fine, but it never "re-projects" the other markers based on the changes I'm making via script. If I do the equivalent thing via the normal GUI interface (clicking the marker, dragging it to a new position), it updates all the other photo projections. Is there a way to trigger this via script?

This is roughly what I'm doing now:

Code: [Select]
from Metashape import Vector
offset = Vector((100, 200))
chunk = Metashape.app.document.chunks[0]
marker = chunk.markers[0]
projection = marker.projections.items()[1]
projection.coord += offset
projection.pinned = True
# I expect other un-pinned projections to be adjusted at this point!

Thanks,
Colin
« Last Edit: May 16, 2019, 11:09:54 PM by colin.spexigeo »

colin.spexigeo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Recalculate marker projections programmatically
« Reply #1 on: May 29, 2019, 04:08:38 AM »
Figured this out by myself. The trick is to run:

Code: [Select]
chunk.refineMarkers([marker])
after pinning at least one projection.