Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: ARF__ 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.
-
hi, I need extract to Python the errors. Can I help me? or not possible?
-
Hello ARF__,
You can try the following for the active chunk (if projected coordinate system is used):
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)
-
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'
>>>
-
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
-
Hello ARF__,
Sorry, instead of marker.location in my code it should be marker.position.
-
It works perfectly, thanks. When I have finished the script that i need, I'll upload to the wiki. Thank you very much
-
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)
-
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.
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)
-
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
-
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.
-
ok.
I'll try it!!