@Override protected boolean canImprove(double distanceSq) { if( distanceSq <= bestDistanceSq ) { return neighbors.size() < searchN || distanceSq < bestDistanceSq; } return false; } }
@Override public boolean isEmpty() { return queue.size() == 0; }
@Override protected boolean canImprove(double distanceSq) { if( distanceSq <= bestDistanceSq ) { return neighbors.size() < searchN || distanceSq < bestDistanceSq; } return false; } }
@Override public int getNumberOfFeatures() { return location.size(); }
@Override public int getNumberOfFeatures() { return foundPoints.size(); }
@Override public GrowQueue_I32 getUnassociatedDestination() { return unassociated.checkDestination(matches,listDst.size()); }
@Override public int getNumberOfFeatures() { return detector.getDetections().size(); }
@Override public GrowQueue_I32 getUnassociatedDestination() { return unassociated.checkDestination(matched,locationDst.size()); }
@Override public void onDraw(Canvas canvas, Matrix imageToView) { canvas.concat(imageToView); synchronized (lockGui) { for (int i = 0; i < foundGUI.size(); i++) { ScalePoint p = foundGUI.get(i); float radius = (float)(p.scale*density); canvas.drawCircle((float) p.x, (float) p.y, radius, paintMax); } } }
/** * Adds a new control point at the specified location. Initially the distorted and undistorted location will be * set to the same * * @param x coordinate x-axis in image pixels * @param y coordinate y-axis in image pixels * @return Index of control point */ public int addControl( float x , float y ) { Control c = controls.grow(); c.q.set(x,y); setUndistorted(controls.size()-1,x,y); return controls.size()-1; }
/** * Remove grids which cannot possible match the expected shape */ static void pruneIncorrectShape(FastQueue<Grid> grids , int numRows, int numCols ) { // prune clusters which can't be a member calibration target for (int i = grids.size()-1; i >= 0; i--) { Grid g = grids.get(i); if ((g.rows != numRows || g.columns != numCols) && (g.rows != numCols || g.columns != numRows)) { grids.remove(i); } } }
private Point2D_I32 findFarthest( FastQueue<Point2D_I32> points , Point2D_I32 a ) { Point2D_I32 best = null; int bestDistance = 0; for( int i = 0; i < points.size(); i++ ) { Point2D_I32 p = points.get(i); int dist = p.distance2(a); if( dist > bestDistance ) { bestDistance = dist; best = p; } } return best; }
void init(Grid grid) { tangents.resize(totalEllipses(grid.rows,grid.columns)); for (int i = 0; i < tangents.size(); i++) { tangents.get(i).reset(); } }
/** * Sets up data structures for nearest-neighbor search used in {@link #connectNodes()} */ private void setupSearch() { searchPoints.reset(); for (int i = 0; i < nodes.size(); i++) { SquareNode n = nodes.get(i); double[] point = searchPoints.grow(); point[0] = n.center.x; point[1] = n.center.y; } search.setPoints(searchPoints.toList(), nodes.toList()); }
@Test public void addAll() { FastQueue<Double> queue = new FastQueue<Double>(100,Double.class,false); List<Double> list = queue.toList(); List<Double> stuff = new ArrayList<Double>(); stuff.add(5.0); stuff.add(10.0); assertTrue(list.addAll(stuff)); assertEquals(2,queue.size()); assertEquals(5.0,queue.get(0),1e-8); assertEquals(10.0, queue.get(1), 1e-8); }
@Test public void add() { FastQueue<Double> queue = new FastQueue<Double>(100,Double.class,false); List<Double> list = queue.toList(); list.add( 5.0 ); assertEquals(1,queue.size()); assertEquals(5.0,queue.get(0),1e-8); }
@Test public void getTail_index() { FastQueue<DummyData> alg = new FastQueue<DummyData>(10,DummyData.class,true); alg.grow();alg.grow(); for (int i = 0; i < alg.size(); i++) { assertTrue(alg.data[i] == alg.getTail(alg.size-i-1)); } }
/** * The tree is empty and it should always fail */ @Test public void findClosest_empty() { KdTreeSearchN<double[]> alg = createAlg(); alg.setTree( new KdTree(2) ); found.reset(); alg.findNeighbor(new double[]{11, 8}, 2, found); assertEquals(0, found.size()); }