@Override public double computeDistance(PointVectorNN pt) { return alg.computeDistance(pt.p); }
/** * Computes the mean and standard deviation of the points from the model */ private void computeMean() { meanError = 0; int size = allPoints.size(); for (PointIndex<Point> inlier : allPoints) { Point pt = inlier.data; meanError += modelError.computeDistance(pt); } meanError /= size; }
/** * Computes the mean and standard deviation of the points from the model */ private void computeMean() { meanError = 0; int size = allPoints.size(); for (PointIndex<Point> inlier : allPoints) { Point pt = inlier.data; meanError += modelError.computeDistance(pt); } meanError /= size; }
private void computeStandardDeviation() { stdError = 0; int size = allPoints.size(); for (PointIndex<Point> inlier : allPoints) { Point pt = inlier.data; double e = modelError.computeDistance(pt) - meanError; stdError += e * e; } stdError = Math.sqrt(stdError / size); } }
private void computeStandardDeviation() { stdError = 0; int size = allPoints.size(); for (PointIndex<Point> inlier : allPoints) { Point pt = inlier.data; double e = modelError.computeDistance(pt) - meanError; stdError += e * e; } stdError = Math.sqrt(stdError / size); } }
@Override public void prune() { double thresh = stdError * pruneThreshold; Iterator<PointIndex<Point>> iter = allPoints.iterator(); while( iter.hasNext() ) { Point pt = iter.next().data; // only prune points which are less accurate than the mean if (modelError.computeDistance(pt) - meanError > thresh) { iter.remove(); } } }
@Override public void computeDistance(List<PointVectorNN> pointVectors, double[] distance) { points.clear(); for (int i = 0; i < pointVectors.size(); i++) { PointVectorNN p = pointVectors.get(i); points.add(p.p); } alg.computeDistance(points, distance); } }
@Override public void prune() { double thresh = stdError * pruneThreshold; Iterator<PointIndex<Point>> iter = allPoints.iterator(); while( iter.hasNext() ) { Point pt = iter.next().data; // only prune points which are less accurate than the mean if (modelError.computeDistance(pt) - meanError > thresh) { iter.remove(); } } }
/** * Finds members of 'shape' in 'points' using a distance test. */ protected void findMembersRigorous(FoundShape shape, List<PointVectorNN> points, List<PointVectorNN> members) { ShapeDescription desc = models.get(shape.whichShape); DistanceFromModel function = desc.modelDistance; double threshold = desc.thresholdFit; function.setModel(shape.modelParam); for (int i = 0; i < points.size(); i++) { PointVectorNN pv = points.get(i); double d = function.computeDistance(pv); if (d <= threshold) { members.add(pv); } } }
/** * Looks for points in the data set which closely match the current best * fit model in the optimizer. * * @param dataSet The points being considered */ @SuppressWarnings({"ForLoopReplaceableByForEach"}) protected void selectMatchSet(List<Point> dataSet, double threshold, Model param) { candidatePoints.clear(); modelDistance.setModel(param); for (int i = 0; i < dataSet.size(); i++) { Point point = dataSet.get(i); double distance = modelDistance.computeDistance(point); if (distance < threshold) { matchToInput[candidatePoints.size()] = i; candidatePoints.add(point); } } }
@Override public void computeStatistics() { int size = allPoints.size(); if (errors.length < size) { errors = new double[size * 3 / 2]; origErrors = new double[errors.length]; } Iterator<PointIndex<Point>> iter = allPoints.iterator(); int index = 0; while( iter.hasNext() ) { Point pt = iter.next().data; errors[index++] = modelError.computeDistance(pt); } System.arraycopy(errors, 0, origErrors, 0, size); int where = (int) (size * pruneThreshold); sorter.sort(errors, size); medianError = errors[size / 2]; pruneVal = errors[where]; }
/** * Exhaustively searches through the list of points contained in 'dataSet' for the set of inliers which match * the provided model. It keeps track of the mapping between the index of the inlier list and the 'dataSet' list * using the matchToInput[] array. If there is no corresponding (can't happen by default) match then -1 * should be set in matchToInput.. * * @param modelDistance Computes */ protected <Model>void selectMatchSet( List<Point> dataSet , DistanceFromModel<Model,Point> modelDistance , double threshold, Model param) { candidatePoints.clear(); modelDistance.setModel(param); for (int i = 0; i < dataSet.size(); i++) { Point point = dataSet.get(i); double distance = modelDistance.computeDistance(point); if (distance < threshold) { matchToInput[candidatePoints.size()] = i; candidatePoints.add(point); } } }
@Override public void computeStatistics() { int size = allPoints.size(); if (errors.length < size) { errors = new double[size * 3 / 2]; origErrors = new double[errors.length]; } Iterator<PointIndex<Point>> iter = allPoints.iterator(); int index = 0; while( iter.hasNext() ) { Point pt = iter.next().data; errors[index++] = modelError.computeDistance(pt); } System.arraycopy(errors, 0, origErrors, 0, size); int where = (int) (size * pruneThreshold); sorter.sort(errors, size); medianError = errors[size / 2]; pruneVal = errors[where]; }
private void compareToShape(FoundShape shape) { ShapeDescription desc = models.get(shape.whichShape); desc.modelDistance.setModel(shape.modelParam); for (int i = 0; i < shape.points.size(); i++) { PointVectorNN pv = shape.points.get(i); int which = cloudToShape.data[pv.index]; if (which < 0) continue; PixelInfo info = shapePixels.get(which); info.matched = true; double d = desc.modelDistance.computeDistance(pv); info.external = Math.min(d, info.external); } }
/** * Looks for points in the data set which closely match the current best * fit model in the optimizer. * * @param dataSet The points being considered */ @SuppressWarnings({"ForLoopReplaceableByForEach"}) protected void selectMatchSet(List<Point> dataSet, double threshold, Model param) { candidatePoints.clear(); modelDistance.setModel(param); for (int i = 0; i < dataSet.size(); i++) { Point point = dataSet.get(i); double distance = modelDistance.computeDistance(point); if (distance < threshold) { matchToInput[candidatePoints.size()] = i; candidatePoints.add(point); } } }
/** * Exhaustively searches through the list of points contained in 'dataSet' for the set of inliers which match * the provided model. It keeps track of the mapping between the index of the inlier list and the 'dataSet' list * using the matchToInput[] array. If there is no corresponding (can't happen by default) match then -1 * should be set in matchToInput.. * * @param modelDistance Computes */ protected <Model>void selectMatchSet( List<Point> dataSet , DistanceFromModel<Model,Point> modelDistance , double threshold, Model param) { candidatePoints.clear(); modelDistance.setModel(param); for (int i = 0; i < dataSet.size(); i++) { Point point = dataSet.get(i); double distance = modelDistance.computeDistance(point); if (distance < threshold) { matchToInput[candidatePoints.size()] = i; candidatePoints.add(point); } } }
private void computeInlierSet(List<Point> dataSet, int n) { int numPts = (int)(n *inlierFrac); if( inlierFrac > 0 && numPts > sampleSize ) { inlierSet.clear(); errorMetric.setModel(bestParam); errorMetric.computeDistance(dataSet,errors); int []indexes = new int[n]; QuickSelect.selectIndex(errors,numPts, n,indexes); for( int i = 0; i < numPts; i++ ) { int origIndex = indexes[i]; inlierSet.add( dataSet.get(origIndex) ); matchToInput[i] = origIndex; } } else { inlierSet = dataSet; } }
private void computeInlierSet(List<Point> dataSet, int n) { int numPts = (int)(n *inlierFrac); if( inlierFrac > 0 && numPts > sampleSize ) { inlierSet.clear(); errorMetric.setModel(bestParam); errorMetric.computeDistance(dataSet,errors); int []indexes = new int[n]; QuickSelect.selectIndex(errors,numPts, n,indexes); for( int i = 0; i < numPts; i++ ) { int origIndex = indexes[i]; inlierSet.add( dataSet.get(origIndex) ); matchToInput[i] = origIndex; } } else { inlierSet = dataSet; } }
/** * Marks points in the point cloud as belonging to this shape for false shape detection * * @param shape */ private void setupShapeForFalse(FoundShape shape) { ShapeDescription desc = models.get(shape.whichShape); shapePixels.reset(); desc.modelDistance.setModel(shape.modelParam); for (int i = 0; i < shape.points.size(); i++) { PointVectorNN pv = shape.points.get(i); cloudToShape.data[pv.index] = i; PixelInfo info = shapePixels.grow(); info.internal = desc.modelDistance.computeDistance(shape.points.get(i)); info.external = Double.MAX_VALUE; info.matched = false; } }
errorMetric.computeDistance(_dataSet,errors);