Loading object_detection/ObjectDetector.java +3 −3 Original line number Diff line number Diff line package vslam.object_detection; package object_detection; public class ObjectDetector { static ObjectSet os; Loading Loading @@ -29,8 +29,8 @@ public class ObjectDetector { new Point(15, 15, 0) ); System.out.println("Added two test points to ObjectSet"); System.out.println("Added two objects of 4 points to ObjectSet"); System.out.println("Indices: " + o1 + ", " + o2); // test out compare boolean same = ObjectSet.compareObjects(o1, o2); if(same){ Loading object_detection/ObjectSet.java +17 −6 Original line number Diff line number Diff line package vslam.object_detection; package object_detection; import java.util.*; public class ObjectSet { static List<PointSet> objects; static int count = 0; public ObjectSet(){ objects = new ArrayList<>(); } Loading @@ -18,11 +18,14 @@ public class ObjectSet { public int makeObject(Point ...pp){ PointSet ps = new PointSet(); ps.addAll(pp); count++; ps.updateReps(); objects.add(ps); // add pointset to object list objects.add(count-1, ps); // return index of new object return (objects.size()-1); return count-1; } /** Loading @@ -35,11 +38,19 @@ public class ObjectSet { Point[] r1 = objects.get(i).getSetReps(); Point[] r2 = objects.get(j).getSetReps(); // compare r1 and r2 Set<Point> s = new HashSet<>(List.of(r1)); Set<Point> s = new HashSet<>(); for(Point r : r1){ if(r != null){ s.add(r); } } int count = 0; for(Point p : r2){ if(s.contains(p)){ if(p!=null && s.contains(p)){ count++; } } Loading object_detection/Point.java +1 −6 Original line number Diff line number Diff line package vslam.object_detection; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; package object_detection; public class Point { Loading object_detection/PointSet.java +6 −7 Original line number Diff line number Diff line package vslam.object_detection; package object_detection; import java.util.*; Loading @@ -18,9 +18,6 @@ public class PointSet { // add every point blankly to pointset pset.addAll(Arrays.asList(pp)); reps = new Point[NUM_REPS]; // initial set of reps this.updateReps(); } public void addPoint(Point p){ Loading @@ -36,7 +33,7 @@ public class PointSet { } public Point[] getSetReps(){ return reps; return this.reps; } public List<Point> getPoints(){ Loading @@ -49,13 +46,15 @@ public class PointSet { */ public void updateReps(){ // get first NUM_REPS from pset for now, will make more efficient later Iterator<Point> iter = this.pset.iterator(); for(int i = 0; i < NUM_REPS; i++){ reps[i] = pset.iterator().next(); // early exit if we have less than NUM_REPS points in the current object if(pset.isEmpty()){ if(i == this.pset.size()) { return; } reps[i] = iter.next(); } } Loading Loading
object_detection/ObjectDetector.java +3 −3 Original line number Diff line number Diff line package vslam.object_detection; package object_detection; public class ObjectDetector { static ObjectSet os; Loading Loading @@ -29,8 +29,8 @@ public class ObjectDetector { new Point(15, 15, 0) ); System.out.println("Added two test points to ObjectSet"); System.out.println("Added two objects of 4 points to ObjectSet"); System.out.println("Indices: " + o1 + ", " + o2); // test out compare boolean same = ObjectSet.compareObjects(o1, o2); if(same){ Loading
object_detection/ObjectSet.java +17 −6 Original line number Diff line number Diff line package vslam.object_detection; package object_detection; import java.util.*; public class ObjectSet { static List<PointSet> objects; static int count = 0; public ObjectSet(){ objects = new ArrayList<>(); } Loading @@ -18,11 +18,14 @@ public class ObjectSet { public int makeObject(Point ...pp){ PointSet ps = new PointSet(); ps.addAll(pp); count++; ps.updateReps(); objects.add(ps); // add pointset to object list objects.add(count-1, ps); // return index of new object return (objects.size()-1); return count-1; } /** Loading @@ -35,11 +38,19 @@ public class ObjectSet { Point[] r1 = objects.get(i).getSetReps(); Point[] r2 = objects.get(j).getSetReps(); // compare r1 and r2 Set<Point> s = new HashSet<>(List.of(r1)); Set<Point> s = new HashSet<>(); for(Point r : r1){ if(r != null){ s.add(r); } } int count = 0; for(Point p : r2){ if(s.contains(p)){ if(p!=null && s.contains(p)){ count++; } } Loading
object_detection/Point.java +1 −6 Original line number Diff line number Diff line package vslam.object_detection; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; package object_detection; public class Point { Loading
object_detection/PointSet.java +6 −7 Original line number Diff line number Diff line package vslam.object_detection; package object_detection; import java.util.*; Loading @@ -18,9 +18,6 @@ public class PointSet { // add every point blankly to pointset pset.addAll(Arrays.asList(pp)); reps = new Point[NUM_REPS]; // initial set of reps this.updateReps(); } public void addPoint(Point p){ Loading @@ -36,7 +33,7 @@ public class PointSet { } public Point[] getSetReps(){ return reps; return this.reps; } public List<Point> getPoints(){ Loading @@ -49,13 +46,15 @@ public class PointSet { */ public void updateReps(){ // get first NUM_REPS from pset for now, will make more efficient later Iterator<Point> iter = this.pset.iterator(); for(int i = 0; i < NUM_REPS; i++){ reps[i] = pset.iterator().next(); // early exit if we have less than NUM_REPS points in the current object if(pset.isEmpty()){ if(i == this.pset.size()) { return; } reps[i] = iter.next(); } } Loading