Community Forum

Author Topic: How to get makers errors  (Read 454 times)

CindyFr

  • Newbie
  • *
  • Posts: 8
    • View Profile
How to get makers errors
« on: November 20, 2017, 06:47:01 PM »
Dear all,

I am quite new in Photoscan scripting, and I try to export markers errors.
I have tried this code in order to have the mean error foreach marker :

Code: [Select]

def computeMeanErrorForeachMarker():
listErrors = []
run = 0
for marker in chunk.markers:
sumError = 0
num = 0
cam = chunk.cameras
for camera in cam:
print(marker)
print(camera)
v_proj = marker.projections[camera].coord
v_reproj = camera.project(marker.position)
diff = (v_proj - v_reproj).norm()
sumError += diff
num += 1
if(num>0):
meanError = sumError / num
else:
meanError = 0
listErrors.append(meanError)
return listErrors

 
listE = computeMeanErrorForeachMarker()
print(listE)


but I have the following error :

"Traceback (most recent call last):
File "C:\ToolsPerso\scripts-photoscan\script_compute_error_by_marker.py", line 31, in <module>
listE = computeMeanErrorForeachMarker()
File "C:\ToolsPerso\scripts-photoscan\script_compute_error_by_marker.py", line 18, in computeMeanErrorForeachMarker
v_proj = marker.projections[camera].coord
AttributeError: 'NoneType' object has no attribute 'coord' "

Can you please help me ?
Ps : I have searched in many topics, but nobody seems to have the same error as me ...

Thanks

Cindy.

CindyFr

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to get makers errors
« Reply #1 on: November 21, 2017, 10:53:09 AM »
Ok, I found some errors in my script :

Code: [Select]
def computeMeanErrorForeachMarker(p_chunk):
listErrors = []
run = 0
for marker in p_chunk.markers:
listTmp = [marker]
sumError = 0
num = 0
cam = p_chunk.cameras
for camera in cam:
print(marker)
print(camera)
v_proj = marker.projections[camera]
if v_proj is None:
print('V_proj est de type None')
continue
v_projc = v_proj.coord
v_reproj = camera.project(marker.position)
diff = (v_projc - v_reproj).norm()
sumError += diff
num += 1
if(num>0):
meanError = sumError / num
else:
meanError = 0
listTmp.append(meanError)

listErrors.append(listTmp)
return listErrors


doc = PhotoScan.app.document
chunk = doc.chunk
listE = computeMeanErrorForeachMarker(chunk)
print(listE)


I get my markers errors, but they are not the same that those displayed in the Reference pane ....

Python script gives :
[[<Marker 'target 1'>, 2.4433671504923136],
[<Marker 'target 2'>, 5.009520853120668],
[<Marker 'target 3'>, 9.195848226433014],
[<Marker 'target 4'>, 36.59943582802248],
[<Marker 'target 5'>, 15.89091610402427],
[<Marker 'target 6'>, 37.653693469253454],
[<Marker 'target 7'>, 18.194628972436924],
[<Marker 'target 8'>, 31.967252685314055],
[<Marker 'target 9'>, 192.8648202514543],
[<Marker 'target 10'>, 4.613443389363529]]


Instead of :
marker 1 : 2.953
marker 2 : 5.643
marker 3 : 15.249
marker 4 : 58.868
marker 5 : 21.155
marker 6 : 41.257
marker 7 : 26.193
marker 8 : 36.196
marker 9 : 279.845
marker 10 : 5.111

Any help please ?
marker 1

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 7813
    • View Profile
Re: How to get makers errors
« Reply #2 on: November 21, 2017, 11:12:04 AM »
Hello CindyFr,

Do you need to get total error in meters, total error in pixels or individual reprojection errors for each marker/camera pair?
Best regards,
Alexey Pasumansky,
AgiSoft LLC

CindyFr

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to get makers errors
« Reply #3 on: November 21, 2017, 12:03:57 PM »
Hello Alexey,

First, thank you for your response :)

In fact, I need to get the accuracy of my 3D model :
I know markers coordinates in real world.
I've put them into Photoscan, and update my model.
Now, i want to know when I pick a point in my model, what is the max error possible ( the interval into my real point can be)

CindyFr

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to get makers errors
« Reply #4 on: November 24, 2017, 11:19:22 AM »
Anybody ?

eriksh

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: How to get makers errors
« Reply #5 on: December 07, 2017, 11:01:19 AM »
If you want the total marker error:

Code: [Select]
doc = PhotoScan.app.document
chunk = doc.chunk

for marker in chunk.markers:
    est = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))  # Gets estimated marker coordinate
    ref = marker.reference.location

    if est and ref:
        error = (est - ref).norm()  # The .norm() method gives the total error. Removing it gives X/Y/Z error
        print(marker.label, error)

That code gives the same error values for me.

CindyFr

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to get makers errors
« Reply #6 on: January 19, 2018, 07:07:59 PM »
Quote
If you want the total marker error:

Code: [Select]

doc = PhotoScan.app.document
chunk = doc.chunk

for marker in chunk.markers:
    est = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))  # Gets estimated marker coordinate
    ref = marker.reference.location

    if est and ref:
        error = (est - ref).norm()  # The .norm() method gives the total error. Removing it gives X/Y/Z error
        print(marker.label, error)


That code gives the same error values for me.


Thank you so much eriksh, i'll test that next week !