Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: CamMakoJ on March 08, 2017, 03:15:45 AM
-
Just wondering if anyone has worked on or made a script that would export the extent of each cameras coverage on the orthophoto.
-
Hello CamMakoJ,
Do you mean something like footprints for each camera or the seamlines of the orthomosaic?
-
Yes exactly, the 'footprint' of each photo would be awesome
-
Hello CamMakoJ,
With the version 1.3.1 release I'll publish the script that will be creating footprint shape layer. We've extended API to make the script in more convenient way.
-
Hello Alexey,
Could you please tell us when you'll provide this script?
Thanks and regards!
-
Hello Seboon,
The following script should be creating the shape layer with the footprints related to the aligned cameras.
Each footprint would have four vertices.
#compatibility PhotoScan Pro 1.3.1
#creates footprint shape layer in the active chunk
import PhotoScan
doc = PhotoScan.app.document
chunk = doc.chunk
if not chunk.shapes:
chunk.shapes = PhotoScan.Shapes()
chunk.shapes.crs = chunk.crs
T = chunk.transform.matrix
footprints = chunk.shapes.addGroup()
footprints.label = "Footprints"
footprints.color = (30, 239, 30)
if chunk.dense_cloud:
surface = chunk.dense_cloud
elif chunk.model:
surface = chunk.model
else:
surface = chunk.point_cloud
for camera in chunk.cameras:
if not camera.transform:
continue #skipping NA cameras
sensor = camera.sensor
corners = list()
for i in [[0, 0], [sensor.width - 1, 0], [sensor.width - 1, sensor.height - 1], [0, sensor.height - 1]]:
corners.append(surface.pickPoint(camera.center, camera.transform.mulp(sensor.calibration.unproject(PhotoScan.Vector(i)))))
if not corners[-1]:
corners[-1] = chunk.point_cloud.pickPoint(camera.center, camera.transform.mulp(sensor.calibration.unproject(PhotoScan.Vector(i))))
if not corners[-1]:
break
corners[-1] = chunk.crs.project(T.mulp(corners[-1]))
if not all(corners):
print("Skipping camera " + camera.label)
continue
if len(corners) == 4:
shape = chunk.shapes.addShape()
shape.label = camera.label
shape.attributes["Photo"] = camera.label
shape.type = PhotoScan.Shape.Type.Polygon
shape.group = footprints
shape.vertices = corners
shape.has_z = True
PhotoScan.app.update()
print("Script finished")
-
Alexey,
Your reactivity is impressive, as always!
Thanks a lot!
-
Thank you. I also happen to be very interested in this functionality, and I am very pleased to see the above script!
-
While it may not be as straightforward as this example, a real help would be the incorporation of masks. It is pretty hard to adjusts masks procedurally without feedback on the resulting coverage.
In other words, I would like to have a preview wether my masks leave holes in the model or the texture, or not.
-
Hello Alexey,
I tried a backdoor modification for Ver. 1.2.6. The console to problem is attached. can you help me identify the problem and mail me same on animesh.ce07@gmail.com
Thanks
-
Hello animesh_PRSD,
The script cannot be ported to the version 1.2.6 due to the lack of the required functions in the old Python API.
The error in the Console, however, states that proper indentation is not used inside "if" clause.
-
Hi Alexey,
My company just buy software Agisoft Metashape, version 2.1 (newer version).
I have similar request, let's say that's similar.
So, state geodetic department of Croatia ask us to send them coordinates of 4 corners of each image footprint - to be visible in images EXIF. They also specified image format in which photos should be exported - .tif format.
Is there a way how to perform that if possible, it not can I somehow
get .txt file where 4 corners of image footprint are stored.
Thank you forwards!
Bye :)
J.K.
-
Hello jkova96,
Do you have an example of the text file that you would like to save? Or it is just camera name and additional eight columns (XY coordinates for 4 corners of image footprint)?
As for the EXIF - what tags should be used to include additional meta data to the images?