# What is Metashape?

Since I am doing image processing for drones in my master's research, is it a 3D construction software called Metashape (formerly Photoscan)? I am using. Originally, image processing was performed on individual images, and it became necessary to obtain the location information of the detected crops. I used to create a mosaic image from individual images in advance, but is it possible to obtain 3D coordinates by finding the points that match the points found in the individual images and the mosaic image? I proceeded based on the hypothesis.

# Understanding the Metashape Python API is hard

Metashape has a Python API, and functions that are not implemented in software can be executed by writing code in Python. However, there are few people who use Metashape or Python API, so even if you search in Japanese, there is not much information.

For example, the blog of the aerial survey laboratory at Yamaguchi University contains information about Metashape, which can be said to be the only one in Japanese. Metashape Python API Note

Perhaps the rest will be information gathering in English. In the Metashape official API explanation, there is a manual of nearly 200 pages, and you will write the code while referring to this.

Metashape Python Reference Release 1.6.0

However, this manual is quite simplified and lacks information to solve the problem at hand. It's unfriendly. Instead, knowledge is accumulated in the question corner called Agisoft forum, which is very helpful.

https://www.agisoft.com/forum/index.php

While referring to the above sites, we will make trial and error.

# Solutions

To summarize what I tried to do, ** Coordinates in the image before mosaic: [x, y] ** From ** 3D coordinates: [X, Y, Z] ** Want to get! about it. It was realized by referring to the following article.

How to add marker using camera's coordinates.

#### `script.py`

``````
import Metashape
doc = Metashape.app.document
chunk = doc.chunk
camera = chunk.cameras[N]
surface = chunk.model
point = surface.pickPoint(camera.center, camera.transform.mulp(camera.sensor.calibration.unproject(Metashape.Vector([x,y]))))