Forum

Author Topic: Export Reprojection Error of each camera station  (Read 6656 times)

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Export Reprojection Error of each camera station
« on: December 18, 2014, 12:53:21 AM »
Hello all,

I would like to ask if I can export the reprojections plus the reprojection error for all camera stations as a txt file with the format as follows: 
Photoname.tif, Reprojections, Reprojection error
I am searching to find a way to do it in Agisoft (without python scripting) like when it is possible to export the estimated camera stations but I cannot find it. So I assume it might be straight forward for python.

Is there any older topic for that?

I want the reprojection error for each camera station because I want to check if there is any correlation between this error and the accuracy achieved with the different number of ground control points (GCPs). So I am processing with Agisoft many times using different number of GCPs and I want to check everytime how much the reprojection error changes.

Thank you in advance for your help
 

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: Export Reprojection Error of each camera station
« Reply #1 on: December 22, 2014, 03:34:55 PM »
Hello b3059651,

Via Python you'll need to calculate reprojection error for each point "manually". I also don't remember if similar script has been already posted on forum, so later I'll provide the sample here.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: Export Reprojection Error of each camera station
« Reply #2 on: December 22, 2014, 04:10:07 PM »
Here's short sample code for PhotoScan 1.1.0 that estimates average reprojection error for all images and also returns dictionary instance that contain camera label, average reprojection error for each image and number of tie-points on each photo.



Code: [Select]
import math
import PhotoScan

def calc_reprojection(chunk):

point_cloud = chunk.point_cloud
points = point_cloud.points
npoints = len(points)
projections = chunk.point_cloud.projections

err_sum = 0
num = 0

photo_avg = {}

for camera in chunk.cameras:
if not camera.transform:
continue

T = camera.transform.inv()
calib = camera.sensor.calibration

point_index = 0

photo_num = 0
photo_err = 0
for proj in projections[camera]:
track_id = proj.track_id
while point_index < npoints and points[point_index].track_id < track_id:
point_index += 1
if point_index < npoints and points[point_index].track_id == track_id:
if not points[point_index].valid:
continue

dist = calib.error(T.mulp(points[point_index].coord), proj.coord).norm() ** 2

err_sum += dist
num += 1

photo_num += 1
photo_err += dist

photo_avg[camera.label] = (math.sqrt(photo_err / photo_num), photo_num)

sigma = math.sqrt(err_sum / num)


rep_avg = sigma

return (rep_avg, photo_avg)


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

total_error, ind_error = calc_reprojection(chunk)
Best regards,
Alexey Pasumansky,
Agisoft LLC

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Export Reprojection Error of each camera station
« Reply #3 on: January 09, 2015, 10:34:26 PM »
Thank you so much for your reply and your provided code.

Though in my University we have the previous version and since we have only educational licence there is a possibility we cannot upgrade into the newer version therefore this code might not work, right?

But I will try it and I will let you know.


Regards,

« Last Edit: January 09, 2015, 10:36:42 PM by b3059651 »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: Export Reprojection Error of each camera station
« Reply #4 on: January 09, 2015, 10:39:10 PM »
Hello b3059651,

You can freely update up to versions 1.9.x with your current license key.
Best regards,
Alexey Pasumansky,
Agisoft LLC

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Export Reprojection Error of each camera station
« Reply #5 on: January 13, 2015, 01:06:52 AM »
Hi Alexey,

I tested the script and it is working well with the new Photoscan version of course. Thank you so much. My only concern is that the dictionary is not the ideal representation if I want to use the error in excel. Is there any way to convert the dictionary directly to a list?

Would something like list=photo_avg.items() work?

Thanks  a lot in advance,
Regards,