Forum

Author Topic: Adjusting marker projection errors via Python  (Read 4862 times)

Wizyza

  • Newbie
  • *
  • Posts: 26
    • View Profile
Adjusting marker projection errors via Python
« on: April 11, 2024, 12:02:26 AM »
Hi everyone,

After detecting markers, I like to go through the markers and remove the more erroneous projections, trying to reach an average error of 0.3 to 0.4 pix per marker. Up to now though, I've only been able to make these adjustments using the GUI.

Is it possible to make these adjustments through the Python API?

Thanks!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15313
    • View Profile
Re: Adjusting marker projection errors via Python
« Reply #1 on: April 12, 2024, 01:37:48 PM »
Hello Wizyza,

Do you have the exact plan what the script should do?

Here is the example how to loop through the marker projections:
Code: [Select]
marker = chunk.markers[-1]

for camera in list(marker.projections.keys()):
    proj = marker.projections[camera].coord #returns three component vector: MetashapeVector([x, y, 0.0])
    #here you can apply some checks if the projection should be removed or not
    #to remove projection: marker.projections[camera] = None
[code]

Best regards,
Alexey Pasumansky,
Agisoft LLC

Wizyza

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Adjusting marker projection errors via Python
« Reply #2 on: April 15, 2024, 02:55:37 AM »
Hi Alexey,

What I would like to do is reduce the mean projection error associated with each marker. To do this, I would start with a target threshold value, say 0.3 px or 0.4 px. If the mean error for a given marker is over that threshold, remove the projection for that marker with the highest error value. If the mean error for the marker remains above the target value, once again, from the remaining projections, remove the projection with the highest error. Continue this process until the mean error for the marker is at or below the target value.

I would then repeat this process for each marker.

I usually do this manually through the GUI, but would like to automate this through scripting.

Thank you again for your help.

Wizyza

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Adjusting marker projection errors via Python
« Reply #3 on: April 16, 2024, 09:58:15 PM »
Hi Alexey,

In order to get the error, I have to pass the coordinates of the point and the pixel coordinates of the point, correct?

I'm guessing from code you provided that the code will provide me with the pixel coordinates of the point? Do I need all three of the values in the vector returned, or just the first two?

How do I go about getting the coordinates of the point?

Thank you again for your help.