Forum

Author Topic: Sort Photos by Quantity of Markers Detected  (Read 4089 times)

johnnokomis

  • Newbie
  • *
  • Posts: 40
    • View Profile
Sort Photos by Quantity of Markers Detected
« on: July 17, 2022, 12:34:36 AM »
Using a turntable and pre-placed markers printed out on a paper, in combination with the "Detect Markers" tool in Metashape. It'd be nice to see what photos in my dataset had the least amount of detected markers. Then, before I even did the alignment step, I knew which photos needed markers manually added to keep the alignment accurate.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Sort Photos by Quantity of Markers Detected
« Reply #1 on: August 24, 2022, 08:48:29 PM »
Hello johnnokomis,

You can use the following script (adds a custom menu item for faster access) that sorts the cameras in the Photos pane according to the number of marker projections placed, cameras with no projections will be filtered out:

Code: [Select]
import Metashape, operator
def filter_photos_by_projections():
chunk = Metashape.app.document.chunk
cam_proj = {}
for marker in chunk.markers:
for camera in marker.projections.keys():
if not (camera in cam_proj.keys()):
cam_proj[camera] = 1
else:
cam_proj[camera] += 1
sorted_cams = sorted(cam_proj.items(), key=operator.itemgetter(1))
sorted_cams = [[x[0]] for x in list(sorted_cams)]
sorted_cams.reverse()
Metashape.app.photos_pane.setFilter(sorted_cams)
Metashape.app.addMenuItem("Custom menu/Filter Photos by Marker Projections", filter_photos_by_projections)
Best regards,
Alexey Pasumansky,
Agisoft LLC

johnnokomis

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: Sort Photos by Quantity of Markers Detected
« Reply #2 on: August 31, 2022, 06:28:39 AM »
That worked perfectly. Thank you.