Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extracting the transformations performed by agisoft's metashape (formerly photoscan) #2

Open
aryarm opened this issue Sep 28, 2019 · 2 comments
Assignees

Comments

@aryarm
Copy link
Member

aryarm commented Sep 28, 2019

This issue documents an attempt at solving the problem in issue #1: that the stitching software, in this case, Agisoft Metashape, does not provide us with information about how it stitched the images together.

Well, it turns out this information is, in fact, available via Metashape's python module. Googling around has indicated that Metashape offers exporting of the "transformation matrix" associated with each "camera" via its python module. You should look into this.

Also, according to an email thread with Agisoft's Support Team, you can create "footprints" for the stitched images and then export them as "shapes in the geographic coordinates." I'll have to look up these quoted terms, which I'm guessing only Agisoft users are familiar with.
Supposedly, you can also export "shape" information for each "orthomosaic block" by clicking on the "Export Orthomosaic" > "Write Tile Scheme" menu option.

Hopefully, one of these options will be helpful. I'll look into them when I get a chance.

@aryarm aryarm self-assigned this Sep 28, 2019
@aryarm
Copy link
Member Author

aryarm commented Oct 9, 2019

Progress

I was able to get Metashape's python module up and running. Then, I found an old Photoscan psx file and used it as test data.
I ran the following python code in the directory with the psx file.

>>> import Metashape
>>> doc = Metashape.Document()
>>> doc.open("Photoscan6:30:17West1.psx")
LoadProject: path = Photoscan6:30:17West1.psx
loaded project in 0.007303 sec
>>> doc.chunk.cameras[0].transform
Matrix([[0.8285324400007574, -0.5585101999137947, -0.04000440549044142, 15.645962579587062],
       [-0.559379418763084, -0.828785418271258, -0.014470532996769135, 35.16350224455201],
       [-0.0250731276602038, 0.03436694710313046, -0.9990947158383662, 5.107038773675241],
       [0.0, 0.0, 0.0, 1.0]])

In the Metashape Python module documentation, this value is referred to as the "4x4 matrix describing photo location in the chunk coordinate system." In order to get a better intuition for what that meant, I read the section entitled "4x4 Matrix Visualized as a Cartesian Coordinate System" in this article.
Although this looks promising, I'm not yet sure whether it is the data we want. But I am at least more confident that spending time with Metashape will give us a viable solution. There are so many functions and attributes available in the Metashape python module documentation, that I'm pretty sure we're bound to get something useful out of this approach.

Another thing to consider

Let's say we're able to figure out exactly how Agisoft stitched the images together. Then we'll still need to somehow apply those transformations to the classification mask that corresponds to that image. How will we do that? Is there a way to do it with the python module or the Metashape GUI? This still seems like a difficult project in itself. You should look into this.
Update: turns out that the attributes of each image are settable, so we could probably transform the classification masks using Agisoft's python module in the same way we do the images?

@aryarm
Copy link
Member Author

aryarm commented Mar 9, 2020

Here's a helpful forum post that demonstrates what I want to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant