Forum

Author Topic: split_in_chunks: Zero Resolution Error (v1.5)  (Read 380 times)

Silent_T

  • Newbie
  • *
  • Posts: 4
    • View Profile
split_in_chunks: Zero Resolution Error (v1.5)
« on: January 17, 2019, 08:54:17 PM »
Hello,
I have received a Zero Resolution error when running the Split In Chunks script to create a dense point cloud. I am using the latest script copied from https://github.com/agisoft-llc/metashape-scripts/blob/master/src/split_in_chunks_dialog.py

I am aware of what the Zero Resolution error means from other posts https://www.agisoft.com/forum/index.php?topic=5109.msg44587#msg44587, and I understand that there are no, or not enough points in the chunk I am processing to create the dense point cloud. See attached screenshot of the 4x4 split that I am processing, the bounding box shown (i.e. 1-4) is the one that stops processing.

However, in the past (before v1.5.0) I have run the script with no problems on chunks with few or no points available to create a dense cloud, similar to this current scenario. The script simply skipped over those chunks with not enough points and didn't create a dense cloud, but continued on processing the other chunks.

In Metashape v1.5 I am getting a Zero Resolution error when the script encounters a chunk with few or no points. Error follows (I have replaced the file location with <FileDir> for brevity):

Quote
File "<FileDir>, line 152, in <lambda>

proc_split = lambda: self.splitChunks()

File "<FileDir", line 286, in splitChunks

new_chunk.buildDenseCloud(max_neighbors=100)  # keep_depth=False

Exception: Zero resolution


I have tried to continue processing from this point using the additional code found in this thread (also pasted below), thinking I could skip it manually with this method: https://www.agisoft.com/forum/index.php?topic=10024.0
Code: [Select]
chunk_labels = [ichunk.label for ichunk in PhotoScan.app.document.chunks]
if  "Chunk " + str(i) + "_" + str(j) in chunk.labels:
    continue

Per the previous threads instructions, I added the above additional code on line 239 (i.e in between the following lines):
Code: [Select]
for i in range(1, partsX + 1):
                if not buildDense:
I Updated "PhotoScan" to "Metashape" and received the following error:
Quote
File "<FileDir>", line 152, in <lambda>

proc_split = lambda: self.splitChunks()

File "<FileDir>", line 240, in splitChunks

chunk_labels = [ichunk.label for ichunk in Metashape.app.document.chunks]

AttributeError: 'Metashape.Chunk' object has no attribute 'labels'

In this case, understand that 'labels' needs to be defined for 'Metashape.Chunk', but I have tried editing the script with my limited coding ability to no success. I can't seem to find a solution to move forward.

Any thoughts on how to get the script to skip chunks with few or no points? Or, as a workaround, how to get the additional script to allow continued processing from what has already been processed? Thanks in advance for any assistance provided.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9897
    • View Profile
Re: split_in_chunks: Zero Resolution Error (v1.5)
« Reply #1 on: January 17, 2019, 09:18:34 PM »
Hello Silent_T,

There seem to be a typo in the code for continuing the job:
Code: [Select]
chunk_labels = [ichunk.label for ichunk in PhotoScan.app.document.chunks]
if  "Chunk " + str(i) + "_" + str(j) in chunk_labels:
    continue
Should be chunk_labels in the second line, not "chunk.labels". I have also corrected it in the original post in another thread.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

LDBL

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: split_in_chunks: Zero Resolution Error (v1.5)
« Reply #2 on: January 17, 2019, 09:22:42 PM »
Apologies for jumping on your thread but I've experienced the same with a different line of code.

Although not entirely the same, I also received zero resolution in v1.5 when python scripting hit

Code: [Select]
chunk.alignCameras()
As above, python script works in previous versions. Also changing python script from
Code: [Select]
PhotoScan. to
Code: [Select]
Metashape. has no bearing on success or failure of script to run...just seems to hit a wall and zero resolution.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9897
    • View Profile
Re: split_in_chunks: Zero Resolution Error (v1.5)
« Reply #3 on: January 17, 2019, 09:36:38 PM »
In order to skip "zero resolution" chunks for the dense cloud generation, you can use try-except approach:


Code: [Select]
try:
   chunk.buildDenseCloud()
except Exception as exc:
    print("Something wrong for chunk ", chunk.label, ". Skipped error: ",exc)
Best regards,
Alexey Pasumansky,
AgiSoft LLC

LDBL

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: split_in_chunks: Zero Resolution Error (v1.5)
« Reply #4 on: January 17, 2019, 09:49:40 PM »
In order to skip "zero resolution" chunks for the dense cloud generation, you can use try-except approach:


Code: [Select]
try:
   chunk.buildDenseCloud()
except Exception as exc:
    print("Something wrong for chunk ", chunk.label, ". Skipped error: ",exc)

Thanks Alexey, will try this.

Silent_T

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: split_in_chunks: Zero Resolution Error (v1.5)
« Reply #5 on: January 17, 2019, 11:49:11 PM »
Hello Alexey,
Thank you for the suggestions. I have tried to implement the exception with limited results. I think I need clarification on where exactly to integrate the code.

I'm assuming your code is meant to replace lines 275-279 and/or 283-288 (shown in the attached screenshot). I have tried doing so in both locations together and separate.

The reason I say I have had limited success is because the result is the creation of all of the split chunks (16 in my case, 4x4), they are just empty (i.e. no dense cloud). I can use these in the batch processing tool like normal, so that is a possibility, albeit not an ideal solution. However, the Build Dense Cloud option within the script no longer works as it is just bypassed. While I do now have a workaround, I'm just curious if I can get this working smoothly...

Can you please clarify what lines you think I should be replacing or inserting and where??
Thank you!

Options I have tried:
1: replacing the statement in after "else"
Code: [Select]
if buildDense:
                    if new_chunk.depth_maps:
                        reuse_depth = True
                        if new_chunk.depth_maps.meta['depth/depth_downscale']:
                            quality = QUALITY[new_chunk.depth_maps.meta['depth/depth_downscale']]
                        if new_chunk.depth_maps.meta['depth/depth_filter_mode']:
                            filtering = FILTERING[new_chunk.depth_maps.meta['depth/depth_filter_mode']]
                        try:
                            new_chunk.buildDepthMaps(quality=quality, filter=filtering, reuse_depth=reuse_depth)
                            new_chunk.buildDenseCloud(max_neighbors=100)  # keep_depth=False
                        except RuntimeError:
                            print("Can't build dense cloud for " + chunk.label)

                    else:
                        reuse_depth = False
                        try:
                            chunk.buildDenseCloud()
                        except Exception as exc:
                            print("Something wrong for chunk ", chunk.label, ". Skipped error: ",exc)


2 replacing the first "try" statement
Code: [Select]
if buildDense:
                    if new_chunk.depth_maps:
                        reuse_depth = True
                        if new_chunk.depth_maps.meta['depth/depth_downscale']:
                            quality = QUALITY[new_chunk.depth_maps.meta['depth/depth_downscale']]
                        if new_chunk.depth_maps.meta['depth/depth_filter_mode']:
                            filtering = FILTERING[new_chunk.depth_maps.meta['depth/depth_filter_mode']]
                        try:
                            chunk.buildDenseCloud()
                        except Exception as exc:
                            print("Something wrong for chunk ", chunk.label, ". Skipped error: ",exc)

                    else:
                        reuse_depth = False
                        try:
                            new_chunk.buildDepthMaps(quality=quality,
                                                     filter=Metashape.FilterMode.AggressiveFiltering, reuse_depth=reuse_depth)
                            new_chunk.buildDenseCloud(max_neighbors=100)  # keep_depth=False
                        except RuntimeError:
                            print("Can't build dense cloud for " + chunk.label)

3 replacing both "try" statements
Code: [Select]
if buildDense:
                    if new_chunk.depth_maps:
                        reuse_depth = True
                        if new_chunk.depth_maps.meta['depth/depth_downscale']:
                            quality = QUALITY[new_chunk.depth_maps.meta['depth/depth_downscale']]
                        if new_chunk.depth_maps.meta['depth/depth_filter_mode']:
                            filtering = FILTERING[new_chunk.depth_maps.meta['depth/depth_filter_mode']]
                        try:
                            chunk.buildDenseCloud()
                        except Exception as exc:
                            print("Something wrong for chunk ", chunk.label, ". Skipped error: ",exc)

                    else:
                        reuse_depth = False
                        try:
                            chunk.buildDenseCloud()
                        except Exception as exc:
                            print("Something wrong for chunk ", chunk.label, ". Skipped error: ",exc)

godszerg

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: split_in_chunks: Zero Resolution Error (v1.5)
« Reply #6 on: March 06, 2019, 07:55:09 PM »
Does anyone solve this Zero resolution problem after splitting in chunks?

Silent_T

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: split_in_chunks: Zero Resolution Error (v1.5)
« Reply #7 on: March 06, 2019, 08:14:29 PM »
Replying to:
Does anyone solve this Zero resolution problem after splitting in chunks?

Using Alexey's suggestions I was able to split the project into chunks, just without doing any processing (Dense Cloud or Mesh creation) using the "split in chunks" dialog. I was able to then build the dense cloud and mesh on all the chunks using the batch processing feature. quote below:
...
The reason I say I have had limited success is because the result is the creation of all of the split chunks (16 in my case, 4x4), they are just empty (i.e. no dense cloud). I can use these in the batch processing tool like normal, so that is a possibility, albeit not an ideal solution. However, the Build Dense Cloud option within the script no longer works as it is just bypassed. While I do now have a workaround, I'm just curious if I can get this working smoothly...
...

So, this process works, but I have not checked for any script updates that might fix the script, nor have I run it since my previous post.