public Model createModel() { Model m; if (unused.isEmpty()) { m = modelManager.createModelInstance(); } else { m = unused.pop(); } used.add(m); return m; } }
/** * Creates a new instance of the ransac algorithm. The number of points sampled will default to the * minimum number. To override this default invoke {@link #setSampleSize(int)}. * * @param randSeed The random seed used by the random number generator. * @param modelGenerator Creates new model(s) given a small number of points. * @param modelDistance Computes the difference between a point an a model. * @param maxIterations The maximum number of iterations the RANSAC algorithm will perform. * @param thresholdFit How close of a fit a points needs to be to the model to be considered a fit. */ public Ransac(long randSeed, ModelManager<Model> modelManager, ModelGenerator<Model, Point> modelGenerator, DistanceFromModel<Model, Point> modelDistance, int maxIterations, double thresholdFit) { this.modelGenerator = modelGenerator; this.modelDistance = modelDistance; this.rand = new Random(randSeed); this.maxIterations = maxIterations; this.bestFitParam = modelManager.createModelInstance(); this.candidateParam = modelManager.createModelInstance(); this.sampleSize = modelGenerator.getMinimumPoints(); this.thresholdFit = thresholdFit; }
/** * Specifies internal algorithms. * * @param surfaceNormals Algorithm used to compute surface normals * @param ransac RANSAC configured with the models its matching * @param minimumPoints The minimum number of points it will need to match * @param shapeList List of shapes matching the RANSAC configuration */ public Ransac_to_PointCloudShapeFinder(ApproximateSurfaceNormals surfaceNormals, RansacMulti<PointVectorNN> ransac, List<ModelManager> modelManagers, List<ModelFitter<Object, PointVectorNN>> fitters, int minimumPoints, List<CloudShapeTypes> shapeList) { this.surfaceNormals = surfaceNormals; this.ransac = ransac; this.fitters = fitters; this.minimumPoints = minimumPoints; this.shapeList = shapeList; for (int i = 0; i < modelManagers.size(); i++) { models.add(modelManagers.get(i).createModelInstance()); } }
/** * Creates a new instance of the ransac algorithm. The number of points sampled will default to the * minimum number. To override this default invoke {@link #setSampleSize(int)}. * * @param randSeed The random seed used by the random number generator. * @param modelGenerator Creates new model(s) given a small number of points. * @param modelDistance Computes the difference between a point an a model. * @param maxIterations The maximum number of iterations the RANSAC algorithm will perform. * @param thresholdFit How close of a fit a points needs to be to the model to be considered a fit. */ public Ransac(long randSeed, ModelManager<Model> modelManager, ModelGenerator<Model, Point> modelGenerator, DistanceFromModel<Model, Point> modelDistance, int maxIterations, double thresholdFit) { this.modelGenerator = modelGenerator; this.modelDistance = modelDistance; this.rand = new Random(randSeed); this.maxIterations = maxIterations; this.bestFitParam = modelManager.createModelInstance(); this.candidateParam = modelManager.createModelInstance(); this.sampleSize = modelGenerator.getMinimumPoints(); this.thresholdFit = thresholdFit; }
/** * Specifies internal algorithms. * * @param surfaceNormals Algorithm used to compute surface normals * @param ransac RANSAC configured with the models its matching * @param minimumPoints The minimum number of points it will need to match * @param maxShapes The maximum number of shapes it will search for * @param shapeList List of shapes matching the RANSAC configuration */ public FindAllOfShapeInCloud(ApproximateSurfaceNormals surfaceNormals, RansacMulti<PointVectorNN> ransac, List<ModelManager> modelManagers, List<ModelFitter<Object, PointVectorNN>> fitters, int minimumPoints, int maxShapes, List<CloudShapeTypes> shapeList) { this.surfaceNormals = surfaceNormals; this.ransac = ransac; this.modelManagers = modelManagers; this.fitters = fitters; this.minimumPoints = minimumPoints; this.maxShapes = maxShapes; this.shapeList = shapeList; for (int i = 0; i < modelManagers.size(); i++) { models.add(modelManagers.get(i).createModelInstance()); } }
this.errorMetric = errorMetric; bestParam = modelManager.createModelInstance(); candidate = modelManager.createModelInstance(); this.sampleSize = generator.getMinimumPoints();
this.errorMetric = errorMetric; bestParam = modelManager.createModelInstance(); candidate = modelManager.createModelInstance(); this.sampleSize = generator.getMinimumPoints();
objectParam.add( o.modelManager.createModelInstance() ); objectCandidateParam.add( o.modelManager.createModelInstance() );
objectParam.add( o.modelManager.createModelInstance() ); objectCandidateParam.add( o.modelManager.createModelInstance() );
this.codec = codec; param = modelManager.createModelInstance(); currParam = modelManager.createModelInstance();
this.codec = codec; param = modelManager.createModelInstance(); currParam = modelManager.createModelInstance();
private void addShapeToOutput(List<PointVectorNN> inliers) { ModelFitter<Object, PointVectorNN> fitter = fitters.get(ransac.getModelIndex()); Object shapeParam = models.get(ransac.getModelIndex()); fitter.fitModel(inliers, ransac.getModelParameters(), shapeParam); // convert the results into output format Shape os = output.grow(); os.parameters = modelManagers.get(ransac.getModelIndex()).createModelInstance(); modelManagers.get(ransac.getModelIndex()).copyModel(shapeParam,os.parameters); os.type = shapeList.get(ransac.getModelIndex()); os.points.clear(); os.indexes.reset(); // add the points to it for (int j = 0; j < inliers.size(); j++) { PointVectorNN pv = inliers.get(j); os.points.add(pv.p); os.indexes.add(pv.index); } }