Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Jordan Pierce

Pages: [1] 2
Python and Java API / Re: Rotate 2D image as it appears in Orthomosiac
« on: February 02, 2024, 06:28:27 PM »
Hello Jordan,

Do you mean to apply a yaw angle rotation to the original photo?

How you are planning to use it? If you need to open images in GIS application with the yaw rotation applied, then using additional World file may be a better solution.

Hi Alexey, I ended up figuring it out. The issue was not with calculating the yaw angle from the camera.transform (see below, for others in the future), but rather the function used to perform the rotation (I think their docs are incorrect):

Code: [Select]
# Your transformation matrix
transformation_matrix = np.array(camera.transform)

# Extract the yaw angle in radians
yaw = np.arctan2(transformation_matrix[1, 0], transformation_matrix[0, 0])

# Convert radians to degrees
yaw_degrees = np.degrees(yaw)

The objective was to show the users the image rotated so they align with what can be viewed in the orthomosaic. I have access to the project file and the API so everything I need was there. Thank you for your response.

Python and Java API / Rotate 2D image as it appears in Orthomosiac
« on: February 02, 2024, 12:43:47 AM »
Hi, just curious if anyone is familiar with using the python api to rotate a 2D image by N degrees to match the view it appears in the orthomosaic?

For future reference, if someone is looking for orthomosaic resolution calculated automatically, you can read it from the report: it's calculated and written there. You just need to scrape the resolution value using a PDF scraper  :o

General / Re: Georeferenced planar orthomosaic (fasade)
« on: March 28, 2023, 12:43:59 AM »
Heelo flogs,

Thanks for the explanation, now I  better understand your needs .. Yes a script could be developped so that for each 2 markers set at base of a building façade, a vertical planar projection is done with the local y set to absolute Z amsl so that each side willl have same height reference... in example a building is shown and for 2 façades (defined each by 2 markers( a relevant planar vertical projection is built. Note each planar ortho has same Z reference as seen by picking top of house and getting Z aMSL (Local Y in ortho CS) equal to 656.4 m...The model is not great so excuse he imperfections, but I think it gives you an idea,

So if you need more explanatio, please PM me,

Yes, that's it. Very common surveying task. I don't need more explation. I know what I want. And now you know what I want. :) The only question remains if it is worth for me to go for python script or maybe there can be some utilization of the software as Alexey sort of suggested (if I felt it right). I will PM you not to bother others here. Thanks very much!

UPDATE: Paulo suggested to create a paid script for this. I am not interested in that. I originally looked for an already existing solution in Metashape. It seems the software has not any right now. So I continue with tweaking it differently or I will find time to solve it myself. Thanks.

In short, for everyone who wants what I want. You have to remove markers projections and edit coordinates of 3 markers in order to create an orthomosaic. Horizontal markers has to be strictly horizontal and verical markers strictly vertical (strictly right angle between markers not required). Aftewards it works pretty well. And then in CAD you have to move the picture to desired absolute height. Not so complicated but maybe still not easy to figure out rigth away for most surveyors.

Hi Flogs, were you able to create a script for generating an orthomosaic that is georeferenced, but in a planar view?


Python and Java API / Overloading PointClass to have custom values
« on: February 17, 2023, 09:56:05 PM »
@Alexey and @paulo is there a way to add custom classes to Metashape.PointClass though the Python API? Is there a definition of these classes in a Python script somewhere within the Metashape applications folder?

Python and Java API / Re: Algorithm of pickPoint Function
« on: February 01, 2023, 01:12:36 AM »
Would also be interested in this.

How could one import a dense cloud as a .ply (or other file format) into metashape using the python api with confidence values included? Essentially a custom dense cloud is being made and I would like to tack on "confidence values" so they can be filtered using the Metashape GUI.


General / Re: Confused about local to geographic conversion
« on: January 09, 2023, 07:47:53 PM »
Hello SFL_Beda,

The internal system of the chunk has arbitrary orientation and scale, you cannot predict, how it will be related to the ECEF or geographic/projected coordinate system before the alignment is completed.

Almost all assets related to the chunk's contents are defined in that internal system:
camera.transform,, region.rot, region.size, marker.position, chunk.model.vertices[N].coord, chunk.point_cloud.points[N].coord and etc.

Hi Alexey,

Similar question: what is the relationship of the coordinate system of the DEM (elevation), Dense Cloud, and Mesh of a project that is not georeferenced? For example, I'm trying to find the connection between indices in an orthomosaic and the dense point cloud, using the elevation of a DEM (where orthomosaic and elevation have the same resolution / dimensions, and are made from the same source: mesh). Because they are both made from the mesh, their connection to is clearer, but if I wanted to project indices of an orthomosaic into 3D such that they match the coordinate system of the dense cloud, is there an additional transformation that needs to be performed?



Python and Java API / Changing the Python Interpreter
« on: January 06, 2023, 01:08:42 AM »

Is it possible to change the python interpreter being used in the Metashape GUI to a custom one (i.e., anaconda)? I have some scripts running from the Metashape GUI that require additional dependencies, and I would rather not install them on the same python interpreter that Metashape uses by default, and instead switch to another one, but still have everything run within the Metashape GUI.


Python and Java API / Re: List of points within dense point cloud
« on: December 20, 2022, 07:39:26 PM »
Hello Jordan,

Dense point cloud points are not accessible via API now. The workaround is to export the dense cloud, apply modification externally and import it back.

Thanks Alexey,

Following this path, is there a way to use selectbycolor using conditional logical to select multiple sets of point clouds based on their color? Using the GUI I can use the tool to select one set of point clouds at a time, however, I'd like to select multiple sets, and export just those sets (as opposed to the whole thing), make edits on those sets, and then import them back to the project to overwrite the existing points.


Python and Java API / List of points within dense point cloud
« on: December 19, 2022, 08:55:53 PM »
How can one obtain a list (or np array) of points within the dense point cloud using the Metashape API? I can see that points within the sparse point cloud can be accessed, as well as the vertices of the mesh. From the dense point cloud you can get the point count, and select using a filter, but how would you get access to the points to change an attribute like the color?


Hello Jordan,

I think that the problem is caused by the fact, that the custom projection matrix is not saved to the exported orthomosaic raster file, so when the import is performed, Metashape doesn't have any information regarding the projection plane.

It might be possible to create custom scripts for export and import of the planar orthomosaic, that will store the projection matrix used for the orthomosaic generation and will consider it for the orthomosaic import.
Do you perform any editing to the exported orthomosaic or what is the purposes or importing it back?

Hi Alexey, that makes sense; does that mean that if the scene is georeferenced using images with GPS information then this problem should no longer occur?

I'm looking to transfer information (modified pixel colors) made on the orthomosaic (after being exported) on to the dense cloud and mesh. Previously I was transferring that information by:

Orthomosaic -> Images -> Dense -> Mesh

But after seeing that Metashape already has an option to colorize the dense and mesh directly via the orthomosaic I've decided to try this route (the latter is also much faster than my previous method, which relies on depth maps and pickPoint). Because these methods do not use a GPU they were a bit slow, but they worked. I have a couple of follow up questions if you don't mind:

- Are there existing functions within MS API that will assist in exporting an orthomosaic with the local coordinate system transformation matrix? If not, I can also look at importing the modified orthomosaic and using the transformation matrix of the original orthomosaic or DEM still within the project (same thing, just different order of operations). Essentially, I need to transfer the transformation matrix from the original orthomosaic or DEM to the modified orthomosaic so I can use the Tasks ColorizeDense and ColorizeVertices...

- If the above doesn't work out, is there a way to modify a point's color within the dense point cloud given the coordinates of the point? I don't recall any functions that give access to the dense point cloud points... If not, I guess I can always export and read it in as a numpy array?

@robotguy16 this post may be of use to you:

Getting close to solving the issue: I oriented the model using the method you mentioned in another post by rotating the model from top, front and then side views.

Now when I try to colorize the mesh using the previously exported orthomosaic it's "more correct", but there's still a translation issue (see below). It doesn't look bad from the top view, but rotating it you can clearly see that it's not right.


If I merge the two orthomosaics together (original, and the original exported and then re-imported) I can see that translation that exists.

Looks like a similar issue these folks were dealing with:

Hello Jordan,

What option you are using for Build Orthomosaic operation? I mean, how the projection plane is selected?

Hi Alexey,

The orthomosaic is being made using an existing mesh, and the Project Plane is current view using a best attempt at looking at the scene from the actual top-down view.


General / Colorizing Dense and Mesh using Export Ortho - Unexpected Results
« on: November 20, 2022, 03:39:06 AM »

I saw that Metashape allows for colorizing the dense cloud and mesh using an orthomosaic, very handy! However, I'm running into unexpected results in specific scenarios and would like to know why. If an ortho is made and the dense cloud and mesh are colorized using said ortho, everything is fine and you can see that the mesh does indeed change (turns black) where there are no data values. However, if that ortho is exported using default parameters and re-imported (no changes to the file) and the same process is performed, the dense cloud and mesh appear to be smeared (see mesh_after_export.png).

The scene is not geo-referenced, the ortho was made using Planar (Current View). Ortho re-imported in Local Coordinates (m) with the No Data value set to 0.


Pages: [1] 2