Forum

Author Topic: how extract Total Error  (Read 6988 times)

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
how extract Total Error
« on: January 31, 2016, 09:16:09 PM »
In Python, how extract the value of Total Error of MARKERS when optimize cameras. I need this function. Thanks.

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: how extract Total Error
« Reply #1 on: February 02, 2016, 03:49:07 PM »
hi, I need extract to Python the errors. Can I help me? or not possible?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14110
    • View Profile
Re: how extract Total Error
« Reply #2 on: February 04, 2016, 02:20:10 PM »
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)
« Last Edit: February 08, 2016, 03:28:45 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: how extract Total Error
« Reply #3 on: February 05, 2016, 01:55:37 PM »
Hello,
Thank you so much. I'll try to see if it is what I'm looking for. Thanks for your time.


It is shown this
2016-02-05 12:13:38     estim = chunk.crs.project(chunk.transform.matrix.mulp(marker.location))
2016-02-05 12:13:38 AttributeError: 'PhotoScan.Marker' object has no attribute 'location'
>>>
« Last Edit: February 05, 2016, 02:16:53 PM by ARF__ »

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: how extract Total Error
« Reply #4 on: February 05, 2016, 09:40:00 PM »
I have already corrected the script ... but I dont understand the values obtained. they are no errors. What is supposed to subtract the script?
SCRIPT:
http://prntscr.com/9zfzy7

RESULTS:
http://prntscr.com/9zg0j5

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14110
    • View Profile
Re: how extract Total Error
« Reply #5 on: February 06, 2016, 12:31:47 AM »
Hello ARF__,

Sorry, instead of marker.location in my code it should be marker.position.
Best regards,
Alexey Pasumansky,
Agisoft LLC

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: how extract Total Error
« Reply #6 on: February 08, 2016, 02:29:11 PM »
It works perfectly, thanks. When I have finished the script that i need, I'll upload to the wiki. Thank you very much

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: how extract Total Error
« Reply #7 on: February 09, 2016, 12:11:35 AM »
Hi,
How PhotoScan calculates the total error?
I calculated the mean square of all errors, and there are differences. There is something wrong in the script?
Thanks


import PhotoScan
import os
import sys

chunk = PhotoScan.app.document.chunk
chunk.markers
#print(chunk.markers[7].label,chunk.markers[7].reference.location) #si pongo entre corchetes un num me da el marker n
listaErrores = []
for marker in chunk.markers:
   source = marker.reference.location # posicion en terreno
   estim = chunk.crs.project(chunk.transform.matrix.mulp(marker.position)) # posicion en modelo
   error = estim - source
   total = error.norm()      #error punto
   SumCuadrado = (total) ** 2    #cuadrado del error
   listaErrores += [SumCuadrado]      #lista de los errores
   #print(marker.label, marker.reference.location, error.x, error.y, error.z, total, SumCuadrado)
print(listaErrores)
import math      #libreria math
suma = 0
n = 0
for i in listaErrores:
   suma = suma + i
   n = n + 1
ErrorTotal = ((suma) / n)**0.5
print(ErrorTotal)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14110
    • View Profile
Re: how extract Total Error
« Reply #8 on: February 09, 2016, 12:26:51 PM »
Hello ARF__,

I've slightly modified your code, so it displays now exactly the same value you get in the Reference pane. local - transformation matrix from geocentric coordinate system.

Code: [Select]
import PhotoScan

chunk = PhotoScan.app.document.chunk

listaErrores = []
for marker in chunk.markers:

   source = chunk.crs.unproject(marker.reference.location) #measured values in geocentric coordinates
   estim = chunk.transform.matrix.mulp(marker.position) #estimated coordinates in geocentric coordinates
   local = chunk.crs.localframe(chunk.transform.matrix.mulp(marker.position)) #local LSE coordinates
   error = local.mulv(estim - source)
   
   total = error.norm()      #error punto
   SumCuadrado = (total) ** 2    #cuadrado del error
   listaErrores += [SumCuadrado]      #lista de los errores
   
#print(listaErrores)

suma = sum(listaErrores)
n = len(listaErrores)
ErrorTotal = (suma / n) ** 0.5

print(ErrorTotal)
Best regards,
Alexey Pasumansky,
Agisoft LLC

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: how extract Total Error
« Reply #9 on: February 22, 2016, 05:20:58 PM »
Hello
Is there some way to calculate the total error, depending on the markers that are selected?

I mean, I have all the selected markers and calculates a total error.
I would like to find all possible combinations between the markers and go getting the value of the total error for each combination.
If I have 50 markers:
1st   total error calculated with 50 markers
2nd  total error calculated combinations of markers 49 until no more possible combinations.
3rd   total error calculated combinations of markers 48 until no more possible combinations
...
...
N     total error calculated with combinations of 3 markers until no more possible combinations

Would it be possible with python?
How are randomly selected markers and combinations of n elements?

thanks and regards

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14110
    • View Profile
Re: how extract Total Error
« Reply #10 on: February 22, 2016, 05:31:33 PM »
Hello ARF__,

You can create multiple lists of markers containing every combination that you are interested in and then loop across all the lists and each marker inside the list.

Or probably the faster way will be to calculate errors for each marker in the project and then deal with the numbers only, to avoid the multiple calculations of the same values.
Best regards,
Alexey Pasumansky,
Agisoft LLC

ARF__

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: how extract Total Error
« Reply #11 on: February 22, 2016, 10:18:46 PM »
ok.
I'll try it!!