Author Topic: Automize Error Reduction - Gradual Selection  (Read 2409 times)


  • Newbie
  • *
  • Posts: 9
    • View Profile
Automize Error Reduction - Gradual Selection
« on: December 14, 2017, 03:53:10 PM »
I'd like to automize my workflow as much as possible. After image matching and camera alignment and a first optimization run I usually delete points by gradual selection.

For example for reducing Reconstruction Uncertainty I use a two step algorithm: 2x deleting points based on threshold and optimizing:
Code: [Select]
def reduce_errors_ru(chunk, thresh=20, config_optimize):
    """ Reduce Reconstruction Uncertainty """
    print(" -> Reconstruction Uncertainty Threshold: {0}".format(thresh))
    pc = chunk.point_cloud
    pnts_init = len(pc.points)
    print(" -> Points before Reconstruction Uncertainty Reduction: {0}".format(pnts_init))
    fltr = ps.PointCloud.Filter()
    fltr.init(chunk, ps.PointCloud.Filter.ReconstructionUncertainty)
    fltr.selectPoints(2 * thresh)
    pnts_inter = pnts_init - len(pc.points)
    print(" -> Removed {0} points".format(pnts_inter))
    pnts_end = pnts_inter - len(pc.points)
    log(" -> Removed {0} points".format(pnts_end))
    log(" -> Points after Reconstruction Uncertainty Reduction: {0}".format(len(pc.points)))

I'd like to calculate the ratio of selected points/total points before actually deleting the points.
(1) How do I count currently selected points in Python API?

Also I'd like to check in a subsequent job, if the error (i.e. Reconstruction Uncertainty) was already reduced.
(2) How do I get a measure of Reconstruction Uncertainty/Projection Accuracy... from within Python? Is it possible to see if points with uncertainty larger than a threshold were already deleted?

Any help is welcome.

Erik Holmlund

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Automize Error Reduction - Gradual Selection
« Reply #1 on: December 14, 2017, 05:44:44 PM »
For your first question, this list comprehension works:
Code: [Select]
pc = chunk.point_cloud
nselected = len([p for p in pc.points if p.selected])

Also, I'm pretty sure a neater way of accomplishing what you want is to use this:
Code: [Select]
And repeat it until the result is better.  The perk of using this, apart from that it's shorter, is that statistical 'outliers' that were removed in previous stages could be reinstated if their errors are reduced to within the threshold.

This however raises a question of mine, which is what these iterations really accomplish? If my knowledge in the bundle adjustment (Camera Optimization) is correct, a similar thresholding is applied and only the points considered valid are used for deciding the orientation. Thus, by removing statistical outliers before, we're just doing the bundle adjustment's job.

Or am I wrong about that? I would love a word from the Agisoft team!

EDIT: Fixed the first script
« Last Edit: December 14, 2017, 05:48:29 PM by eriksh »