Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: adamjg on July 17, 2020, 02:39:51 PM

Title: Unknown error from chunk.detectMarkers()
Post by: adamjg on July 17, 2020, 02:39:51 PM
Hi,

I'm recieving two intermittent errors from chunk.detectMarkers() and wondering if anyone knows why...

Code: [Select]
free(): invalid next size (normal)
Code: [Select]
corrupted size vs. prev_size
Title: Re: Unknown error from chunk.detectMarkers()
Post by: Alexey Pasumansky on August 09, 2020, 01:22:44 AM
Hello adamjg,

If you are observing this problem in Metashape Pro 1.6.3, please provide the code lines that can be used to reproduce the issue.
Title: Re: Unknown error from chunk.detectMarkers()
Post by: william on May 04, 2021, 05:12:41 PM
I'm also seeing the same error consistently in chunk.detectMarkers():
Code: [Select]
free(): invalid next size (normal)
I'm not sure if it's connected, but when I run Metashape.app.enumGPUDevices(), these log messages show up:
Code: [Select]
clGetPlatformIDs failed: CL_UNKNOWN_ERROR_CODE_-1001
Found 0 GPUs in 0.039938 sec (CUDA: 0.024209 sec, OpenCL: 0.015694 sec)

I will try to find the exact code to reproduce this, and post again here shortly.
Title: Re: Unknown error from chunk.detectMarkers()
Post by: Alexey Pasumansky on May 04, 2021, 05:35:03 PM
Hello William,

The second problem is likely related to the installed GPU drivers, so driver update is recommended.

As for the initial problem, it could be caused by the RAM failures, so if you are observing the problem only on one machine (providing that you can check the same procedure on any other computer), it may be reasonable to run overnight Memtest86 checks in multi-threaded mode.
Title: Re: Unknown error from chunk.detectMarkers()
Post by: william on May 04, 2021, 06:16:32 PM
Hi again,

I will take your advice and try to run memory tests. However, in the meantime, I have created the means to perfectly reproduce the error, just in case it is not related to my hardware/firmware.

Here is a dropbox link to the images (one full capture of RedEdge MX Blue, i.e. 5 files): https://www.dropbox.com/s/nanql7exftqqno0/images.zip?dl=0 (https://www.dropbox.com/s/nanql7exftqqno0/images.zip?dl=0)

And here is the code to reproduce:

Code: [Select]

import Metashape
import glob

images_dir='/path/to/images_dir'
paths=glob.glob(images_dir + '/*')

doc = Metashape.Document()
chunk = doc.addChunk()
chunk.addPhotos(filenames=paths, layout=Metashape.MultiplaneLayout)
# AddPhotos: layout = MultiplaneLayout
# lm optimize: xxxx--------x-x-x--x-x-------- 1.24813 -> 4.88783e-14
# Calibration initialized, mean error = 6.91244e-14 pix, max error = 3.21555e-13 pix
# lm optimize: xx--- 0.0538587 -> 0.00957659
# Vignetting initialized, mean error = 0.0102956, max error = 0.0351406
# lm optimize: xxxx--------x----------------- 1.30994 -> 4.87049e-14
# Calibration initialized, mean error = 6.88791e-14 pix, max error = 3.21555e-13 pix
# lm optimize: xx--- 0.0702812 -> 0.00656294
# Vignetting initialized, mean error = 0.00708867, max error = 0.0220412
# lm optimize: xxxx------------------x------- 1.37761 -> 4.86505e-14
# Calibration initialized, mean error = 6.88023e-14 pix, max error = 4.54747e-13 pix
# lm optimize: xxx-- 0.0525239 -> 0.0067085
# Vignetting initialized, mean error = 0.00728809, max error = 0.0285493
# lm optimize: xxxx--------x----------x-x---- 1.393 -> 4.9437e-14
# Calibration initialized, mean error = 6.99145e-14 pix, max error = 4.68743e-13 pix
# lm optimize: xx--- 0.0924907 -> 0.00521566
# Vignetting initialized, mean error = 0.00592781, max error = 0.0213214
# lm optimize: xxx--------------------------- 1.37947 -> 5.04523e-14
# Calibration initialized, mean error = 7.13504e-14 pix, max error = 4.58286e-13 pix
# lm optimize: xx--- 0.11524 -> 0.00838645
# Vignetting initialized, mean error = 0.0101272, max error = 0.0395673

chunk.detectMarkers(target_type=Metashape.CircularTarget12bit, tolerance=100)
# DetectMarkers: marker type = Circular 12 bit, tolerance = 100 
# free(): invalid next size (normal)
# Aborted (core dumped)
Title: Re: Unknown error from chunk.detectMarkers()
Post by: william on May 04, 2021, 06:18:55 PM
In fact, using my own code & data that I just posted, I was able to successfully detect markers on a different machine. So it is certainly a problem with the machine. I will look into the Memtest. Thanks for the very quick reply!
Title: Re: Unknown error from chunk.detectMarkers()
Post by: Alexey Pasumansky on May 04, 2021, 06:36:13 PM
Hello William,

Thank you for sharing the dataset and sample code. However, it works as expected on my test system:
Code: [Select]
chunk.detectMarkers(target_type=Metashape.CircularTarget12bit, tolerance=100)
2021-05-04 18:35:16 DetectMarkers: marker type = Circular 12 bit, tolerance = 100
2021-05-04 18:35:16 Detecting markers...
2021-05-04 18:35:17 0200ccd6-7809-4cb4-869c-55ead3f74e41__IMG_0089_8: 0 targets
2021-05-04 18:35:17 2a50712c-8ebf-4e62-8b49-b7fa7920a993__IMG_0089_7: 0 targets
2021-05-04 18:35:17 26a8624f-01f8-4a89-9a67-e26863640c0f__IMG_0089_10: 0 targets
2021-05-04 18:35:17 da161590-ec3a-4665-9df5-1a60ce6c1823__IMG_0089_9: 0 targets
2021-05-04 18:35:17 355177db-1a7f-4fea-a8e3-499f3a7a963a__IMG_0089_6: 0 targets
2021-05-04 18:35:17 Finished processing in 0.394 sec (exit code 1)

If there are multiple RAM modules installed on the system, where the problem is observed, you can also try to leave only one module at a time and check, if the issue is observed on the certain one module. In case it is reproducible on any module, you may need to lower the RAM frequency.
Title: Re: Unknown error from chunk.detectMarkers()
Post by: william on May 05, 2021, 08:56:52 PM
Just a quick update:

It turned out that both of the errors for me were caused by the fact that I was accidentally using Metashape 1.6.2 -- I had forgotten to pip install Metashape 1.7.2, even though my code was written for 1.7.2. Updating the Metashape version fixed everything.

So for future reference, folks: If you see either of the errors I saw, it could just be a Metashape versioning problem!