Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - sydneyg

Pages: [1]
1
Python and Java API / output consecutive cameras from matching
« on: November 02, 2022, 06:03:20 PM »
Hi everyone,

I'm working on processing an archive of historical aerial photos automatically. The images are labelled by day, but the flightlines from the same day in many cases are not connected to each other. I need to know how to split the images into chunks for the automated processing without having to look at hand-drawn maps of the flight lines.

My understanding is that Metashape does some kind of initial brute-force matching to figure out which images might be consecutive. Is there any possible way to export a list of images that contain matches together?


Thanks for the help,
Sydney

2
Python and Java API / Re: detectFiducials fails randomly
« 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.


3
Python and Java API / Re: import fiducials from txt
« on: September 14, 2022, 06:41:13 PM »
Thank you Alexey, with a few little changes it worked just fine.

Best,

Sydney

4
Python and Java API / import fiducials from txt
« on: September 09, 2022, 04:25:47 PM »
Hi everyone,

I'm working on some historical photos. I have in a txt file a list of fiducial coordinates for each image in pixels (image coordinates), as well as a calibrated position for those fiducials from a certificate.

I'm wondering how is the best way to import those from a file for each image? I see that for chunk.importReference there is no option to create a marker type Fiducial.

Best,

Sydney

5
Python and Java API / Re: detectFiducials fails randomly
« 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

6
Python and Java API / 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

7
Hello Alexey,

Thank you for the help, it worked perfectly.

Just to know this is how it looked in the code in the end:

Code: [Select]
for camera in chunk.cameras:
   sensor = camera.sensor
   sensor.fixed_calibration=True
   sensor.film_camera=True
   sensor.focal_length=<focal len>
   sensor.height = 0
   sensor.width = 0

for f in sensor.fiducials:
   coord = f.reference.location
   print(coord)
   f.reference.location = Metashape.Vector([coord.x, -coord.y, coord.z])
   print(f.reference.location)


Sydney

8
Hi all,

I am trying to work with some historical aerial imagery (from a film camera with fiducials).  I cannot seem to get the images to align with the script I have.

My script detects the fiducials automatically, calibrates them, and masks out the background, and matches the photos. All of that seems to work fine, but the final alignment produces 0 tie points. When I run this script without the flag "film camera with fiducials", the images align and a sparse cloud is made. However, when the film camera comes into the question it seems to find 0 tie points. 

PS: I also slammed the same images into the GUI and processed with the same setup as I have here in this script (film camera w/ fiducials auto detected and auto calibrated) and the images aligned just fine. 

PPS: I also tested it with a different set of historical aerial film images, same issue again. So I don't think the images are the issue.

Does anyone have any insights on this? Maybe I'm overlooking something in this script. Script attached as is the console output. Thx for the help.

Sydney

9
Hi all, I'm currently working with some historical aerial imagery with the Metashape python modules and I had a few questions:

1. Is it possible to run matchPhotos using a reference orthomosaic to create GCPs? in other words,  find IPs within a reference orthomosaic to "create" GCPs for by matching features in the historical imagery for the bundle adjustment (e.g. where the GCPs would have coordinates in e.g. WGS84 from the reference and corresponding match points in image coordinates?).

2. If #1 is not possible, would it then be possible to import pre-existing interest points as GCPs? Specifically, I have coordinates taken from a coarse reference ortho in lat/long/elev and related to image coordinates X(mm from PPA)/Y(mm from PPA) for each image that I have already created in Ames stereo pipeline, would it be possible to somehow integrate those as GCPs? In other words, for each image, can I relate a pixel coordinate to a Ground control marker, and then use that info to complete the bundle adjustment? If so, how would I go about doing that in python?

Thank you for any help,

Sydney

Pages: [1]