Forum

Author Topic: depth maps are not saved when looping over frames  (Read 1389 times)

forumname

  • Newbie
  • *
  • Posts: 36
    • View Profile
depth maps are not saved when looping over frames
« on: February 27, 2022, 08:36:44 PM »
I am building the depth maps through the python API (in Spyder IDE) within a loop, as follows:


for frame in chunk.frames:
    frame.buildDepthMaps(downscale=1, filter_mode=Ms.NoFiltering)

doc.save()


It completes and saves successfully, and says X depth maps were completed. I can verify that the depth_maps folder was created in the project.files directory. However, when I open the project within Metashape GUI, no depth maps are found. Furthermore, if I close the python console, the directories are all deleted immediately. This happens even if doc.save() is called within the loop, or if the loop contains the dense cloud building:


frame.buildDenseCloud(point_confidence=True, keep_depth=True)


However, the depth maps can be properly saved when frames are called manually, e.g.,


chunk.frames[0].buildDepthMaps(downscale=1, filter_mode=Ms.NoFiltering)

doc.save()


The maps are also saved properly if created within the Metashape GUI.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: depth maps are not saved when looping over frames
« Reply #1 on: March 01, 2022, 03:54:58 PM »
Hello forumname,

Do you observe the same problem if you create a simple script that opens the project with the alignment results, generates depth maps (as in your example) and saves the project? I mean, if you call the script from the command line: metashape.exe -r script.py
Best regards,
Alexey Pasumansky,
Agisoft LLC

forumname

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: depth maps are not saved when looping over frames
« Reply #2 on: March 10, 2022, 07:11:29 PM »
Hi Alexey,

Running from command line does not help. In fact, now the alignment is also not being, although it was before. Intermediate steps like duplicating chunks are still being run. Running the script from the Metashape GUI Run Script... dialogue also does not save the alignment.

I confirmed that the calibration can be manually processed within the Metashape GUI.


EDIT: I found the alignment is a separate issue caused by calling doc.save(path) instead of doc.save(). The depth maps continue to be deleted after creation even if calling metashape from the terminal.

EDIT2: This has apparently been solved. Because of other code, I was calling doc.open(path) before each new block. I guess reopening the document caused a conflict so Metashape didn't recognize the save and treated all the output files as temporary, so they were all deleted as usual when shutting down.
« Last Edit: March 11, 2022, 06:40:38 PM by forumname »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: depth maps are not saved when looping over frames
« Reply #3 on: March 21, 2022, 05:22:23 PM »
Hello forumname,

Good to hear, that you have been able to track down the reason of the problem and fix it.
Best regards,
Alexey Pasumansky,
Agisoft LLC