Forum

Author Topic: Possible way to get a footprint of a crop of an image?  (Read 4971 times)

srathore

  • Newbie
  • *
  • Posts: 4
    • View Profile
Possible way to get a footprint of a crop of an image?
« on: June 03, 2023, 09:09:12 PM »
I'm slightly new to using Metashape but some of my research requires me to essentially look at a crop of an image taken by a drone camera (center crop), I know its possible to get the footprint of a camera from the list and there was a n old script for that in the forums. But is it possible to make a script to export/ get the footprint of a 2000x2000 crop of a 8192x5460 image taken by a DJI drone camera?

Paulo

  • Hero Member
  • *****
  • Posts: 1378
    • View Profile
Re: Possible way to get a footprint of a crop of an image?
« Reply #1 on: June 03, 2023, 10:19:23 PM »
Hello srathore,

from the github script https://github.com/agisoft-llc/metashape-scripts/blob/master/src/footprints_to_shapes.py#L50, you would need to edit the following that takes the four pixel corner coordinates  of an image:
Code: [Select]
        for (x, y) in [[0, 0], [sensor.width - 1, 0], [sensor.width - 1, sensor.height - 1], [0, sensor.height - 1]]:to something like:
Code: [Select]
        for (x, y) in [[2000, 2000], [4000, 2000], [4000, 4000], [2000,4000]]:to reflect a 2000 by 2000 image crop from position u=2000 pix and v=2000 pix....

PS. to get a crop centered, I guess you would need to define the 4 point list as:
Code: [Select]
[[hw-1000, hh-1000], [hw+1000, hh-1000], [hw+1000, hh+1000], [hw-1000, hh+1000]]
where:
        hw = camera.sensor.width/2
        hh = camera.sensor.height/2
Hope this can help,
« Last Edit: June 04, 2023, 07:16:24 PM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

srathore

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Possible way to get a footprint of a crop of an image?
« Reply #2 on: June 06, 2023, 07:29:28 AM »
That, looks like it worked, thanks a lot. Is there a way I could export these values?

Paulo

  • Hero Member
  • *****
  • Posts: 1378
    • View Profile
Re: Possible way to get a footprint of a crop of an image?
« Reply #3 on: June 06, 2023, 04:11:10 PM »
Hi again,

if you mean exporting the polygons created by the footprints2shapes script, you can look at chunk.exportShapes method . From API reference manual, p.39:

Code: [Select]
exportShapes(path='', save_points=False, save_polylines=False, save_polygons=False[, groups ],
format=ShapesFormatNone[, crs ][, shift ], polygons_as_polylines=False, save_labels=True,
save_attributes=True[, progress ])
Best Regards,
Paul Pelletier,
Surveyor

ankit108

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Possible way to get a footprint of a crop of an image?
« Reply #4 on: June 20, 2023, 06:40:00 PM »
Hello Paulo,
I have a similar question. What work around should I do to get the footprint of an Orthomosaic like we got footprint for each camera in the question mentioned above?
By footprint of ortho, I meant that a shape that follows boundary of an Ortho.

Paulo

  • Hero Member
  • *****
  • Posts: 1378
    • View Profile
Re: Possible way to get a footprint of a crop of an image?
« Reply #5 on: June 21, 2023, 02:41:34 PM »
Hello ankit,

one workaround would be to generate seamlines from Orthomosaic context menu (right click on ortho in Workspace). This will create a shapes layer with seamlines as multi polygons. See attachment... You could then export this layer and in a Gis software combine all the seamlines multi polygons into one polygon representing the ortho footprint.....
Best Regards,
Paul Pelletier,
Surveyor