Forum

Author Topic: Addition of GCP images data using Python API  (Read 1934 times)

aniket@aus.co.in

  • Newbie
  • *
  • Posts: 25
    • View Profile
Addition of GCP images data using Python API
« on: March 08, 2022, 02:15:20 PM »
We want to first load GCP data in the form of comma separated values,

GCP label, X, Y, Z

here X, Y, Z are longitude, latitude and altitude.

And further we want to add GCP points to the chunk using the API in form of CSV again.

GCP label, Image label, X, Y

here X and Y pixel coordinates of the GCP in image.


What is the best possible way to do it?

Paulo

  • Hero Member
  • *****
  • Posts: 1352
    • View Profile
Re: Addition of GCP images data using Python API
« Reply #1 on: March 08, 2022, 08:30:40 PM »
Hi aniket,

for loading GCP data you may look at chunk.importReference() method in Python reference manual, p.43.

Then for second part, you would need to read in each line (GCP label, Image label, X, Y) of your csv and do following  :

Code: [Select]
chunk = Metashape.app.document.chunk
marker = [m for m in chunk.markers if m.label == 'GCP label'][0]
camera = [c for c in chunk.cameras if c.label ==  'Image label'][0]
coord = Metashape.Vector([X,Y])
marker.projections[camera] = Metashape.Marker.Projection(coord,True)


Hope this can get you started,
Best Regards,
Paul Pelletier,
Surveyor