Hi,
Through the Metashape API 1.6.2, I am actively looking to develop a script that will automatically process a list of 2D coordinates on all cameras/image in a list of chunks. The output result will be the list of 3D point positions in the project cartographic coordinate, mostly UTM.
The 2D image coordinate list would be constant and contain 14336 (X,Y) pairs. Yes, that a lot.
This script should be executed after of all procedures (Camera alignment, optimization, Camera alignment, dense cloud, mesh, DEM and ortho).
I'm having trouble finding my way around. There are many point projection functions in the Metashape API.
Below is the beginning of a first draft script:
import Metashape
import numpy as np
#Load coord list from external numpy file:
Img2DCoordList = np.load("***.npy")
chunk2Process = ["chunk name #1", "chunk name #2"]
chunks = Metashape.app.document.chunks
if not len(chunks):
Metashape.app.messageBox("No chunk!")
exit()
Metashape.app.messageBox("-Start-")
for chunk in chunks:
if chunk.label in chunk2Process:
Metashape.app.messageBox("Process with Chunk :{0}".format(chunk.label))
cameras = chunk.cameras
if not len(cameras):
Metashape.app.messageBox("No camera in this chunk called {0}!".format(chunk.label))
continue
for cam in cameras:
pnt = Img2DCoordList[0] # 1 point for testing
### exploration ###
# 1.
# Parameter : Coordinates of the point to be projected (as Vector);
# Output : Returns a 2D coordinates, as vector, of the point projection on the photo;
cam.project(pnt)
# 2.
# Parameter : Projection coordinates (as Vector);
# Output : returns a 3D coordinates, as vector, which will have specified projected coordinates;
cam.unproject(pnt)
# 3.
# 3.1 Create a marker from pnt
# 3.2 Project the marker from a way or another
# 3.3 Retrieve the 3D coordinates
# [code]
# 4.
# Any ideas?
Many thanks,