Forum

Author Topic: Build a function to compute error projection and nr of projection of one camera  (Read 2736 times)

Seb_B

  • Newbie
  • *
  • Posts: 38
    • View Profile
Hello,

How can I write a function which returns the projection numbers camera and the projection error of each cameras?

I tryied to build this function based on the code from:
http://www.agisoft.com/forum/index.php?topic=3189.msg16800#msg16800

But It seems to not compute the right projection number and the projection error!

Code: [Select]
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 = {}

photo_info=[[float('nan') for j in range(3)] for i in range(len(chunk.cameras))]#Ajout seb
i=-1
#print("total camera number: ",len(chunk.cameras))
for camera in chunk.cameras:
i+=1
if not camera.transform:
photo_info[i]=[camera,float('nan'),float('nan')]
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
#Ajout seb
#print("i:",i)
if photo_num==0:
photo_info[i]=[camera,photo_num,float('nan')]
else:
photo_info[i]=[camera,photo_num,math.sqrt(photo_err / photo_num)]
return photo_info

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14854
    • View Profile
Hello Seb_B,

I've checked your function on a random project and got actually identical results via Python and in GUI.
Best regards,
Alexey Pasumansky,
Agisoft LLC