Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: Seb_B on March 24, 2015, 12:43:36 AM

Title: Getting projection error of markers
Post by: Seb_B on March 24, 2015, 12:43:36 AM
Hello,

How can we have the error (in pixel) of the markers after the aligning step?
Something like :
marker=chunk.markers[1]
marker.projections.error         ->wrong
Title: Re: Getting projection error of markers
Post by: Alexey Pasumansky on March 24, 2015, 12:27:09 PM
Hello Sebastien,

You need to calculate the errors manually, by projecting the 3D point (marker.position) on the corresponding images and then calculate the difference in pixels between projected point coordinates and original marker projection.
Title: Re: Getting projection error of markers
Post by: Alexey Pasumansky on March 24, 2015, 01:27:52 PM
For example, for single projection of marker on the give photo:
Code: [Select]
marker = chunk.markers[0]
photo = chunk.cameras[0]

v_proj = marker.projections[photo].coord #2 dimensional vector of the marker projection on the photo
v_reproj = photo.project(marker.position) #2 dimensional vector of projected 3D marker position

diff = (v_proj - v_reproj).norm() #reprojection error for current photo
Title: Re: Getting projection error of markers
Post by: mauchi on November 08, 2015, 08:40:01 PM
Hi Alexey,

Forgive the late joining to this discussion. Is there a way to export the data from python like there is in the gui? I am having the same problem where some of my markers have errors but with 144 cameras to sort through for each it would be ideal to have access to the data that is already in agisoft.

Thank you!

Mauchi
Pixelgun

Title: Re: Getting projection error of markers
Post by: Alexey Pasumansky on November 09, 2015, 06:28:03 PM
Hello Mauchi,

What information do you wish to be exported? Source/estimated values, reprojection error of each marker for every camera?
Title: Re: Getting projection error of markers
Post by: Yoann Courtois on November 06, 2018, 01:02:07 PM
Hi !

Is there a new way to export reprojection error in pixel with 1.4 API ?

Regards
Title: Re: Getting projection error of markers
Post by: Yoann Courtois on November 06, 2018, 01:18:01 PM
This reprojection error could be add to such process to export "all in one" about markers

Hello ARF__,

You can try the following for the active chunk (if projected coordinate system is used):

Code: [Select]
import PhotoScan

chunk = PhotoScan.app.document.chunk

for marker in chunk.markers:
      source = marker.reference.location
      estim = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))
      error = estim - source
      total = error.norm()
      print(marker.label, error.x, error.y, error.z, total)
Title: Re: Getting projection error of markers
Post by: Alexey Pasumansky on November 06, 2018, 04:22:52 PM
Hello Yoann,

Doesn't this code work in 1.4 to display RMSE for the marker reprojection erro?

Code: [Select]
import math
total =0
num = 0
for camera in chunk.cameras:
    if not camera in marker.projections.keys():
        continue
    v_proj = marker.projections[camera].coord #2 dimensional vector of the marker projection on the photo
    v_reproj = camera.project(marker.position) #2 dimensional vector of projected 3D marker position

    diff = (v_proj - v_reproj).norm() #reprojection error for current photo
    total += diff ** 2
    num +=1
print(math.sqrt(total / num))

Title: Re: Getting projection error of markers
Post by: Yoann Courtois on November 06, 2018, 04:44:38 PM
Perfect !  8)
Thanks