Forum

Author Topic: Reprojection Error for each point of the sparse point cloud  (Read 8579 times)

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Reprojection Error for each point of the sparse point cloud
« on: March 08, 2015, 09:07:29 PM »
Hi all,

I would like to ask if there is any way to export the reprojection error for each point of the sparse point cloud as a separate column after X-Y-Z coordinate columns, so to visualize the error with other GIS package?
Is this feasible in python or Agisoft?


Thanks a lot for your reply in advance,

Regards,
Maria


b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #1 on: March 10, 2015, 05:09:54 PM »
Hi again,

I found this thread http://www.agisoft.com/forum/index.php?topic=3029.msg16118#msg16118.
Is it possible to have an example of the command to get the reprojection error from each point in the sparse point cloud?

Thanks a lot in advance
Regards,
Maria

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #2 on: March 10, 2015, 06:27:39 PM »
Hello Maria,

So you wish to export sparse point cloud to text file with the following information:
        x-coord, y-coord, z-coord, reproj-error
Right? Should the coordinates be in the same system defined in the Reference pane settings?
Best regards,
Alexey Pasumansky,
Agisoft LLC

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #3 on: March 10, 2015, 07:54:13 PM »
Hi Alexey,

Yes, exactly this. With the coordinate system as set in the panel.




Thanks,
Regards,
Maria

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #4 on: April 17, 2015, 05:56:15 PM »
Hi all,

It would be nice if somebody can help with how to export the reprojection error for each tie point of the sparse point cloud.

Regards,
Maria

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #5 on: May 26, 2015, 03:07:57 PM »
Hello Maria,

Sorry for the late reply.

Please try the following script:

Code: [Select]
# Compatibility - Agisoft PhotoScan Professional 1.1.6
# saves reprojection error for the tie points in the cloud

# export format:
# point_index X-coord Y-coord Z-coord reproj_error

import PhotoScan
import math, time

doc = PhotoScan.app.document
chunk = doc.chunk
M = chunk.transform.matrix
crs = chunk.crs
point_cloud = chunk.point_cloud
projections = point_cloud.projections
points = point_cloud.points
npoints = len(points)
tracks = point_cloud.tracks

path = PhotoScan.app.getSaveFileName("Specify export path and filename:")
file = open(path, "wt")
print("Script started")

t0 = time.time()

points_coords = {}
points_errors = {}

for photo in chunk.cameras:

if not photo.transform:
continue

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

point_index = 0
for proj in projections[photo]:
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
v = M.mulp(points[point_index].coord)

if point_index in points_errors.keys():
point_index = int(point_index)
points_errors[point_index].x += dist
points_errors[point_index].y += 1
else:
points_errors[point_index] = PhotoScan.Vector([dist, 1])

for point_index in range(npoints):

if not points[point_index].valid:
continue

if chunk.crs:
X, Y, Z = chunk.crs.project(M.mulp(points[point_index].coord))
else:
X, Y, Z = M.mulp(points[point_index].coord)

error = math.sqrt(points_errors[point_index].x / points_errors[point_index].y)

file.write("{}\t{:.6f}\t{:.6f}\t{:.6f}\t{:.6f}\n".format(point_index, X, Y, Z, error))

t1 = time.time()

file.flush()
file.close()
print("Script finished in " + str(int(t1-t0)) + " seconds.")
Best regards,
Alexey Pasumansky,
Agisoft LLC

b3059651

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #6 on: May 26, 2015, 04:20:44 PM »
Thank you so much!!

I will let you know how it works :)

bigben

  • Sr. Member
  • ****
  • Posts: 406
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #7 on: May 27, 2015, 06:25:47 AM »
Looks interesting. Will have to play with this and Cloud Compare for evaluating results of different experiments

jason.liu

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #8 on: September 29, 2015, 12:22:42 PM »
What unit is the reprojection error in?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #9 on: September 29, 2015, 01:11:06 PM »
Hello jason.liu,

It's in pixels.
Best regards,
Alexey Pasumansky,
Agisoft LLC

jason.liu

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #10 on: October 14, 2015, 11:43:23 AM »
Hello jason.liu,

It's in pixels.

Just another dumb question: wouldn't it be in pixel square? since in the code you did norm()**2

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #11 on: October 14, 2015, 01:38:07 PM »
Hello jason.liu,

"dist" variable is not a error value that is saved to the file, lower you can find "error" variable definition that is a RMS value.
Best regards,
Alexey Pasumansky,
Agisoft LLC

jason.liu

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Reprojection Error for each point of the sparse point cloud
« Reply #12 on: October 15, 2015, 10:02:30 AM »
Thanks. I didn't see that math.sqrt.