Hello!
I'm running the following script to get reprojection errors by point of the point cloud:
def tiepointsRMS(path, i=[0]):
i[0] += 1
"""
Generates a TXT file with point index of Sparse Cloud, associated
coordinates and calculated reprojection error (pIndex, X, Y, Z, error)
"""
point_cloud = chunk.point_cloud
projections = point_cloud.projections
points = point_cloud.points
npoints = len(points)
M = chunk.transform.matrix
file = open(path + str(i) + ".txt", "wt")
print("Tiepoints reprojection error calculations started...")
t0 = time.time()
points_errors = {}
for photo in chunk.cameras:
if not photo.transform:
continue
T = photo.transform.inv()
calib = photo.sensor.calibration
pIndex = 0
for proj in projections[photo]:
track_id = proj.track_id
while pIndex < npoints and points[pIndex].track_id < track_id:
pIndex += 1
if pIndex < npoints and points[pIndex].track_id == track_id:
if not points[pIndex].valid:
continue
coord = T * points[pIndex].coord
coord.size = 3
dist = calib.error(coord, proj.coord).norm() ** 2
v = M * points[pIndex].coord
v.size = 3
if pIndex in points_errors.keys():
pIndex = int(pIndex)
points_errors[pIndex].x += dist
points_errors[pIndex].y += 1
else:
points_errors[pIndex] = PS.Vector([dist, 1])
for pIndex in range(npoints):
if not points[pIndex].valid:
continue
if chunk.crs:
w = M * points[pIndex].coord
w.size = 3
X, Y, Z = chunk.crs.project(w)
else:
X, Y, Z, w = M * points[pIndex].coord
error = math.sqrt(points_errors[pIndex].x /
points_errors[pIndex].y)
file.write("{:6d}\t{:.6f}\t{:.6f}\t"
"{:.6f}\t{:.6f}\n".format(pIndex, X, Y, Z, error))
t1 = time.time()
file.close()
print("Script finished in " + str(int(t1-t0)) + " seconds.")
While it succeeds to calculate the reprojection error for each tie point, when I compare the max error value obtained with script (14,5876 pix) with the max error provided by chunk info (21.8388 pix) they don't match. Is that supposed to happen? Looking forward for the reply.
Regards!