Loading src/main/java/object_detection/ObjectDetector.java +4 −6 Original line number Diff line number Diff line Loading @@ -5,11 +5,8 @@ import object_detection.types.Point; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.List; public class ObjectDetector { Loading @@ -30,8 +27,9 @@ public class ObjectDetector { int NUMKF = feat_CSVs.length; for(int i = 0; i < NUMKF; i++){ // single KeyFrame //ArrayList<ArrayList<Point>> currFrame = objSet.processFrame(feat_CSVs[i], bbox_CSVs[i]); // process the frame List<ArrayList<Point>> currFramePoints = objSet.processFrame(feat_CSVs[i], bbox_CSVs[i]); objSet.updateObjectSet(currFramePoints); } // return the completely built object set Loading src/main/java/object_detection/types/BoundingBox.java +0 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,4 @@ public class BoundingBox { Point2D botRight; Point2D botLeft; int idx; } src/main/java/object_detection/types/ObjectSet.java +36 −3 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ public class ObjectSet { * @return true if objects are the same */ public static boolean compareObjects(int i, int j){ Point[] r1 = objects.get(i).getSetReps(); Point[] r2 = objects.get(j).getSetReps(); Point[] r1 = objects.get(i).getPoints(); Point[] r2 = objects.get(j).getPoints(); // compare r1 and r2 Set<Point> s = new HashSet<>(); Loading Loading @@ -75,8 +75,10 @@ public class ObjectSet { // remove j objects.remove(j); // eventually, push i to database // lower the count count--; // eventually, push i to database } /** Loading @@ -87,6 +89,9 @@ public class ObjectSet { */ public List<ArrayList<Point>> processFrame(File featCsv, File bboxCsv) throws FileNotFoundException { // Print the name of the file being processed System.out.println("Processing " + featCsv.getName() + " and " + bboxCsv.getName()); // Read bounding boxes List<BoundingBox> boundingBoxes = readBoundingBoxes(bboxCsv); Loading @@ -96,9 +101,15 @@ public class ObjectSet { results.add(new ArrayList<>()); } int lineNum = 0; // Process feature points Scanner scanner = new Scanner(featCsv); while (scanner.hasNextLine()) { // Print the line of the file being processed System.out.println("Processing line " + lineNum++); String[] line = scanner.nextLine().split(","); Point2D point2D = new Point2D(Float.parseFloat(line[0]), Float.parseFloat(line[1]), Integer.parseInt(line[2])); Point point = new Point(Float.parseFloat(line[3]), Float.parseFloat(line[4]), Float.parseFloat(line[5]), Integer.parseInt(line[2])); Loading @@ -116,6 +127,28 @@ public class ObjectSet { return results; } /** * This method updates the existing ObjectSet to incorporate new information from the features and bounding boxes of a new keyframe. * It also updates the ObjectSet to merge objects that are similar. * * @param points : the features of the new keyframe of the form List<ArrayList<Point>> * */ public void updateObjectSet(List<ArrayList<Point>> points) { for (int i = 0; i < points.size(); i++) { Point[] pointArray = points.get(i).toArray(new Point[0]); int objIdx = makeObject(pointArray); // Compare the new object with all existing objects for (int j = 0; j < objects.size(); j++) { if (compareObjects(objIdx, j)) { combineObjects(j, objIdx); break; } } } } private List<BoundingBox> readBoundingBoxes(File bboxCsv) throws FileNotFoundException { List<BoundingBox> boxes = new ArrayList<>(); Scanner scanner = new Scanner(bboxCsv); Loading src/main/java/object_detection/types/PointSet.java +12 −2 Original line number Diff line number Diff line Loading @@ -38,8 +38,18 @@ public class PointSet { return this.reps; } public List<Point> getPoints(){ return new ArrayList<>(pset); /* * This method is used to get the points in the PointSet */ public Point[] getPoints(){ Iterator<Point> iter = this.pset.iterator(); Point[] res = new Point[this.pset.size()]; for(int i = 0; i < this.pset.size(); i++){ res[i] = iter.next(); } return res; } /** Loading target/classes/object_detection/ObjectDetector.class +322 B (1.88 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
src/main/java/object_detection/ObjectDetector.java +4 −6 Original line number Diff line number Diff line Loading @@ -5,11 +5,8 @@ import object_detection.types.Point; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.List; public class ObjectDetector { Loading @@ -30,8 +27,9 @@ public class ObjectDetector { int NUMKF = feat_CSVs.length; for(int i = 0; i < NUMKF; i++){ // single KeyFrame //ArrayList<ArrayList<Point>> currFrame = objSet.processFrame(feat_CSVs[i], bbox_CSVs[i]); // process the frame List<ArrayList<Point>> currFramePoints = objSet.processFrame(feat_CSVs[i], bbox_CSVs[i]); objSet.updateObjectSet(currFramePoints); } // return the completely built object set Loading
src/main/java/object_detection/types/BoundingBox.java +0 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,4 @@ public class BoundingBox { Point2D botRight; Point2D botLeft; int idx; }
src/main/java/object_detection/types/ObjectSet.java +36 −3 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ public class ObjectSet { * @return true if objects are the same */ public static boolean compareObjects(int i, int j){ Point[] r1 = objects.get(i).getSetReps(); Point[] r2 = objects.get(j).getSetReps(); Point[] r1 = objects.get(i).getPoints(); Point[] r2 = objects.get(j).getPoints(); // compare r1 and r2 Set<Point> s = new HashSet<>(); Loading Loading @@ -75,8 +75,10 @@ public class ObjectSet { // remove j objects.remove(j); // eventually, push i to database // lower the count count--; // eventually, push i to database } /** Loading @@ -87,6 +89,9 @@ public class ObjectSet { */ public List<ArrayList<Point>> processFrame(File featCsv, File bboxCsv) throws FileNotFoundException { // Print the name of the file being processed System.out.println("Processing " + featCsv.getName() + " and " + bboxCsv.getName()); // Read bounding boxes List<BoundingBox> boundingBoxes = readBoundingBoxes(bboxCsv); Loading @@ -96,9 +101,15 @@ public class ObjectSet { results.add(new ArrayList<>()); } int lineNum = 0; // Process feature points Scanner scanner = new Scanner(featCsv); while (scanner.hasNextLine()) { // Print the line of the file being processed System.out.println("Processing line " + lineNum++); String[] line = scanner.nextLine().split(","); Point2D point2D = new Point2D(Float.parseFloat(line[0]), Float.parseFloat(line[1]), Integer.parseInt(line[2])); Point point = new Point(Float.parseFloat(line[3]), Float.parseFloat(line[4]), Float.parseFloat(line[5]), Integer.parseInt(line[2])); Loading @@ -116,6 +127,28 @@ public class ObjectSet { return results; } /** * This method updates the existing ObjectSet to incorporate new information from the features and bounding boxes of a new keyframe. * It also updates the ObjectSet to merge objects that are similar. * * @param points : the features of the new keyframe of the form List<ArrayList<Point>> * */ public void updateObjectSet(List<ArrayList<Point>> points) { for (int i = 0; i < points.size(); i++) { Point[] pointArray = points.get(i).toArray(new Point[0]); int objIdx = makeObject(pointArray); // Compare the new object with all existing objects for (int j = 0; j < objects.size(); j++) { if (compareObjects(objIdx, j)) { combineObjects(j, objIdx); break; } } } } private List<BoundingBox> readBoundingBoxes(File bboxCsv) throws FileNotFoundException { List<BoundingBox> boxes = new ArrayList<>(); Scanner scanner = new Scanner(bboxCsv); Loading
src/main/java/object_detection/types/PointSet.java +12 −2 Original line number Diff line number Diff line Loading @@ -38,8 +38,18 @@ public class PointSet { return this.reps; } public List<Point> getPoints(){ return new ArrayList<>(pset); /* * This method is used to get the points in the PointSet */ public Point[] getPoints(){ Iterator<Point> iter = this.pset.iterator(); Point[] res = new Point[this.pset.size()]; for(int i = 0; i < this.pset.size(); i++){ res[i] = iter.next(); } return res; } /** Loading
target/classes/object_detection/ObjectDetector.class +322 B (1.88 KiB) File changed.No diff preview for this file type. View original file View changed file