Forum

Author Topic: detectFiducials fails randomly  (Read 2084 times)

sydneyg

  • Newbie
  • *
  • Posts: 9
    • View Profile
detectFiducials fails randomly
« on: August 30, 2022, 02:21:18 PM »
Hi all, I'm working on some historical aerial photos currently. Strangely, about 4 out of 5 times when I try to start the script, it terminates at some random point during detectFiducials part. The error that I get is usually is something like:

Code: [Select]
free() : invalid pointer
I have realized that this has to do with the memory, but I can't seem to find anything wrong with the memory. Nor does it seem to be overwhelming the memory when I monitor while it's processing. It's also curious that it doesn't happen every time, sometimes the processing works.

Another strange point is that I keep getting this error as well, not sure if it's related or affects the processing at all:

Code: [Select]
OMP: Info #276: omp_set_nested routine depreciated, please use omp_set_max_active_levels instead.
Does anyone have any idea what's going on here? Thanks for any help,

Sydney

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: detectFiducials fails randomly
« Reply #1 on: August 30, 2022, 03:35:15 PM »
Hello Sydney,

can you please share the script lines that can be used to reproduce the problem (limiting the code to a fewer number of lines would help to isolate the issue)? Also please specify, if the same code fails frequently on any scanned images with the fiducial marks or on particular type of marks? And let me know about the scanned images dimensions in pixels, so that we could try to reproduce it on our side.
Best regards,
Alexey Pasumansky,
Agisoft LLC

sydneyg

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: detectFiducials fails randomly
« Reply #2 on: August 30, 2022, 07:05:23 PM »
Hello Alexey,

Thanks for the quick answer. I have tested now a few different sets of scanned images, both at 15 and 16 micron resolution, and I get the same issue. If I only process a few images at a time, like 5 or 6 then it works fine, but the second I add a lot of images to the chunk (like more than 10), I get this error. I have also tried it now on a different machine with more memory and still same issue.

As for the fiducial types, the same happens for the two different types of fiducials I have tried (attached). If it doesn't crash, it seems to detect the fiducials correctly in most cases...


The script I run where it fails is like this (I shortened the beginning a bit where I import the images, I hope this is ok):

Code: [Select]
createMasks = False
film_camera = True
pixel_width = 0.015
pixel_height = pixel_width
F = 152.82


for camera in chunk.cameras:
    sensor = camera.sensor
    sensor.film_camera = film_camera
    calibration = sensor.calibration
    sensor.fixed_calibration = False
    sensor.focal_length = F
    sensor.pixel_height = pixel_height
    sensor.pixel_width = pixel_width
    if film_camera == True:
        sensor.height = 0
        sensor.width = 0

    ## combine all cameras of the same sensor size and pixel size into the same camera:
    for i in range(1, len(chunk.cameras)):
        camera = chunk.cameras[i]
        prev = chunk.cameras[i-1]
        if (camera.sensor.width == prev.sensor.width) and (camera.sensor.height == prev.sensor.height):
            if (camera.sensor.pixel_height == prev.sensor.pixel_height) and (camera.sensor.pixel_width == prev.sensor.pixel_width):
                if camera.sensor.focal_length == prev.sensor.focal_length:
                    camera.sensor = prev.sensor

if findFiducials == True:
    chunk.detectFiducials(generate_masks = createMasks)
    print("Found the following fiducials in the images: ")
    for marker in chunk.markers:
        print(marker.label)

This last part of the code is where it fails, at chunk.detectFiducials, usually after it has already detected fiducials in a few iamges. Interestingly, I also tried opening the project in the GUI and also same problem, it crashes after it detects fiducials in a few images. As far as I can tell I can't find any pattern for when it fails or not, but it definitely does not handle detecting fiducials in a lot of images at a time.

Thanks for the help,

Sydney

sydneyg

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: detectFiducials fails randomly
« Reply #3 on: October 26, 2022, 05:51:38 PM »
Hi -- Just wanted to update that I accidentally found a solution to this problem in case anyone is interested:

I put detectFiducials inside a separate function like this:

Code: [Select]
def findFiducials(chunk):
    chunk.detectFiducials(generate_masks=False)

For some reason this got rid of the errors I had before.