Forum

Author Topic: Deleting duplicate cameras  (Read 2772 times)

mwillis

  • Full Member
  • ***
  • Posts: 140
    • View Profile
Deleting duplicate cameras
« on: July 07, 2019, 04:02:18 PM »
Hi, there was a script in Photoscan to remove duplicate cameras (photos) from a chunk.  Is there a version of that script available for Metashape?

Thanks,

Mark

mwillis

  • Full Member
  • ***
  • Posts: 140
    • View Profile
Re: Deleting duplicate cameras
« Reply #1 on: July 07, 2019, 04:20:11 PM »
By the way, I tried this but it took away some photos that were properly aligned and left some that were not.

import Metashape, os

chunk = Metashape.app.document.chunk
print("start")
paths = set()
photos = list()
for camera in list(chunk.cameras):
      if camera.photo.path in paths:
             photos.append(camera)
      else:
             paths.add(camera.photo.path)

chunk.remove(photos)
print("finished. %d duplicates removed" % len(photos))


I believe what I actually need to do first is have the script delete all disabled cameras and then remove duplicates.  Is there a way to sort for disabled cameras?

Thanks again,

Mark
« Last Edit: July 08, 2019, 12:18:38 AM by mwillis »

mwillis

  • Full Member
  • ***
  • Posts: 140
    • View Profile
Re: Deleting duplicate cameras
« Reply #2 on: July 07, 2019, 04:33:06 PM »
Sorry for the bother. I figured it out.

If someone in the future wonders what I did, I sorted by alignment in the Photo Pane, deleted all NA photos, and then ran the script above.  That left me with only one version of every camera that was aligned.
« Last Edit: July 08, 2019, 12:18:01 AM by mwillis »