Forum

Author Topic: Delete images from harddrive  (Read 1877 times)

geri

  • Newbie
  • *
  • Posts: 11
    • View Profile
Delete images from harddrive
« on: August 13, 2020, 11:27:57 AM »
Hi everybody,

due to a certain way of taking our pictures along an axis, we sometimes have duplicate images or images with extremely high overlap (>99%). Initially I thought, that's not a problem, but during the optimization-step, these pictures produce a very high pixel-error, leading to a strange result.
Nevertheless, I found out, if I delete those images and run the step over again, everything is fine.

Now I REALLY want to delete those images, not just from the chunk or the project, but from the hard drive. It is possible by right-clicking on the image, choose "open containing folder", deleting it manually and also delete it in agisoft. this is okay for several pictures, but sometimes it exceeds 50 pictures per project, which is annoying.

What want to do is create a button or shortcut to do that routine for me. So i just have to select the image, press the shortcut and it magically is removed from both the project and the hard drive.

Is that possible in any way?

Thank you!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14817
    • View Profile
Re: Delete images from harddrive
« Reply #1 on: August 27, 2020, 10:12:54 PM »
Hello geri,

How do you see this option in order to be convenient to you?

For example: select the cameras in Metashape and then run script that will remove the cameras from the chunk and corresponding images from the hard drive?
Or point to the image containing directory and allow the script to remove all the images from the subfolders which do not correspond to any cameras in chunk or in project.
Best regards,
Alexey Pasumansky,
Agisoft LLC

geri

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Delete images from harddrive
« Reply #2 on: August 28, 2020, 01:00:46 PM »
hi,

the first option:
"select the cameras in Metashape and then run script that will remove the cameras from the chunk and corresponding images from the hard drive"

thanks.

geri

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Delete images from harddrive
« Reply #3 on: September 03, 2020, 11:27:50 AM »
Hi Alexey,

any news regarding my problem?

wojtek

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Delete images from harddrive
« Reply #4 on: September 11, 2020, 02:24:21 PM »
Hey, i scripted this for you:

Code: [Select]
import Metashape
import os

docRef = Metashape.app.document
chunk = docRef.chunk

selected_cameras = [cam for cam in chunk.cameras if cam.selected]

for camera in selected_cameras:

    photo_path = camera.photo.path
    os.remove(photo_path)
    camera.enabled = False

Also attached a .py file. This will remove files from the disk and disable the cameras (selected).