Forum

Author Topic: How to get camera location accuracy?  (Read 2689 times)

BorodinMaxim

  • Newbie
  • *
  • Posts: 5
    • View Profile
How to get camera location accuracy?
« on: August 17, 2022, 07:52:27 PM »
How to get the accuracy of the camera estimate as in the screenshot


P.S.
Code: [Select]
chunk.cameras[0].reference.accuracy is None # True

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15074
    • View Profile
Re: How to get camera location accuracy?
« Reply #1 on: August 17, 2022, 08:21:54 PM »
Hello Maxim,

The following script allows to save to the text file total number of tie point projections and tie point reprojection error (as marked on your screenshot) per aligned camera:
Code: [Select]
import Metashape, math

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 = camera.error(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 = Metashape.app.document
chunk = doc.chunk
path = Metashape.app.getSaveFileName("Specify the export path:")
file = open(path, "wt")
total_error, ind_error = calc_reprojection(chunk)
file.write("\t".join(["#label","error_pix","proj_num\n"]))
for camera in ind_error.keys():
file.write("\t".join([camera, str(ind_error[camera][0]), str(ind_error[camera][1])])+"\n")
file.close()


camera.reference.accuracy is used to specify the measurement accuracy of the camera location coordinates.
Best regards,
Alexey Pasumansky,
Agisoft LLC

BorodinMaxim

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: How to get camera location accuracy?
« Reply #2 on: August 18, 2022, 10:25:40 AM »
Alexey, thanks to