Forum

Author Topic: Process Depth Maps only?  (Read 8556 times)

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Process Depth Maps only?
« on: March 24, 2020, 12:17:38 AM »
Hi,

Does anyone know if there's such a script or an option to process Depth Maps only?

I've already have the option checked to keep the depth maps in the preferences, but I don't want to build meshes straight after, i would rather do each step for a bunch of chunks all in one go.

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
Re: Process Depth Maps only?
« Reply #1 on: March 24, 2020, 03:45:07 AM »
Hi 3D Scan fan,

to create just the depth maps for your active chunk, just use:

Code: [Select]
#builddepth High quality fo all cameras
Metashape.app.document.chunk.buildDepthMaps(downscale=2, filter_mode=Metashape.FilterMode.MildFiltering, reuse_depth=False, max_neighbors=-1, subdivide_task=True, workitem_size_cameras=20, max_workgroup_size=100)
Best Regards,
Paul Pelletier,
Surveyor

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Process Depth Maps only?
« Reply #2 on: March 24, 2020, 04:06:30 AM »
Thanks very much for that.

What if I want to do it for a bunch of chunks? Or a Batch Process?

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
Re: Process Depth Maps only?
« Reply #3 on: March 24, 2020, 05:57:15 AM »
For this in python, just loop thru all chunks in your document as:
Code: [Select]
doc = Metashape.app.document

for chunk in doc.chunks:
    chunk.buildDepthMaps(downscale=2, filter_mode=Metashape.FilterMode.MildFiltering, reuse_depth=False, max_neighbors=-1, subdivide_task=True, workitem_size_cameras=20, max_workgroup_size=100)

In batch, I do not think there is a build Depth maps option....
« Last Edit: March 24, 2020, 10:12:53 AM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Process Depth Maps only?
« Reply #4 on: March 24, 2020, 02:54:00 PM »
I need for it to replicate the setting I usually do in Metashape, that being the quality=Ultra High Quality and Mild Filtering.

I don't understand the parameters of that script, what is downscale? filtermode? max neighbours? subdivide? cameras? workgroup?

I don't recall all of this stuff. I even tried reading the Metashape Python reference and it doesn't exactly explain what it means :(

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Process Depth Maps only?
« Reply #5 on: March 24, 2020, 03:40:49 PM »
Hello 3D_Scan_Fan,

downscale is what is named "quality" in GUI. Where 0 - is Ultra, 1 - High, 2 - Medium, 4 - Low. filter_mode is "depth filtering".

Other parameters can be skipped, and the default values will be used.
Best regards,
Alexey Pasumansky,
Agisoft LLC

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Process Depth Maps only?
« Reply #6 on: March 24, 2020, 04:55:31 PM »
I'm running this script but I'm not seeing the Depth Maps being stored in the chunks :(

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Process Depth Maps only?
« Reply #7 on: March 24, 2020, 06:31:31 PM »
Now I've left it running and Metashape has completed hanged, frozen.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Process Depth Maps only?
« Reply #8 on: March 24, 2020, 07:08:39 PM »
Hello 3D_Scan_Fan,

How many chunks and how many images in each do you have?
Best regards,
Alexey Pasumansky,
Agisoft LLC

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Process Depth Maps only?
« Reply #9 on: March 24, 2020, 11:46:34 PM »
Okay, it seems to be working at the moment.

How do I process Depth Maps for all the chunks in the project?

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
Re: Process Depth Maps only?
« Reply #10 on: March 25, 2020, 05:23:03 AM »
I you want to generate Ultra High quality depth maps with mild filtering for all chunks in your project just enter following:

Code: [Select]
doc = Metashape.app.document

for chunk in doc.chunks:
    chunk.buildDepthMaps(downscale=1, filter_mode=Metashape.FilterMode.MildFiltering)

Downscale parameter of 1 corresponds to Ultra High
Best Regards,
Paul Pelletier,
Surveyor

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Process Depth Maps only?
« Reply #11 on: March 25, 2020, 05:42:16 AM »
Thanks.

Will this affect all chunks, including those that have been "disabled"?

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
Re: Process Depth Maps only?
« Reply #12 on: March 25, 2020, 06:11:42 AM »
Yes it should affect all chunks in project, including disabled

If you want to skip disabled chunks add:
Code: [Select]
doc = Metashape.app.document

for chunk in doc.chunks:
    if not chunk.enabled:
        continue
    chunk.buildDepthMaps(downscale=1, filter_mode=Metashape.FilterMode.MildFiltering)
Best Regards,
Paul Pelletier,
Surveyor

3D_Scan_Fan

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Process Depth Maps only?
« Reply #13 on: March 25, 2020, 04:54:11 PM »
Thanks for that.

Would this script also work for Photoscan 1.3.5.?

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
Re: Process Depth Maps only?
« Reply #14 on: March 25, 2020, 07:27:41 PM »
Sorry, no it would not as buildDepthMaps method was introduced in version 1.4 see https://agisoft.freshdesk.com/support/solutions/articles/31000138369-function-builddensecloud-doesn-t-work-anymore-in-1-5
Best Regards,
Paul Pelletier,
Surveyor