Commit 16a1df6b authored by Rohan  Kumar's avatar Rohan Kumar
Browse files

finally working

parent 10d0415f
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -84,8 +84,10 @@ public class MongoDBInteraction {

        // Using Integer.parseInt to safely convert String to Integer if necessary
        int idx;
        String pred;
        try {
            idx = doc.get("setId") instanceof Integer ? (Integer) doc.get("setId") : Integer.parseInt((String) doc.get("setId"));
            pred = (String) doc.get("predName");
        } catch (NumberFormatException e) {
            System.err.println("Invalid format for setId, must be an integer: " + doc.get("setId"));
            return null;
@@ -93,10 +95,10 @@ public class MongoDBInteraction {

        List<Document> pointsDocs = doc.getList("points", Document.class);
        if (pointsDocs == null) {
            return new PointSet(idx);
            return new PointSet(idx, pred);
        }

        PointSet pointSet = new PointSet(idx);
        PointSet pointSet = new PointSet(idx, pred);
        for (Document pointDoc : pointsDocs) {
            Point point = new Point(
                    pointDoc.getDouble("x").floatValue(),
@@ -123,6 +125,7 @@ public class MongoDBInteraction {
                    .append("B", p.B));
        }
        return new Document("setId", setId)
                .append("predName", pointSet.getPred())
                .append("points", pointsList);
    }

+1 −35
Original line number Diff line number Diff line
@@ -17,22 +17,11 @@ public class ObjectDetector {

    /**
     * The starting function that creates an object set, compiles informatino, and returns it
     * @throws FileNotFoundException
     * @throws FileNotFoundException : if files have not been created yet
     */
    public static void startProcess(String dataset) throws IOException, CsvValidationException {

        // for now, we can just set paths to the directories that hold keyframes and featurepoint CSVs
<<<<<<< HEAD
        String bbox_dir_pth = "src/main/java/vslam/BoundedInfo";
        String pose_dir_path = "src/main/java/vslam/CameraPoses";

        if (dataset.equals("1")) {
            bbox_dir_pth = "src/main/java/vslam/tum_rgbd/BoundedInfo";
            pose_dir_path = "src/main/java/vslam/tum_rgbd/CameraPoses";
        } else if (dataset.equals("2")) {
            bbox_dir_pth = "src/main/java/vslam/imperial_london/BoundedInfoTUM";
            pose_dir_path = "src/main/java/vslam/imperial_london/CameraPosesTUM";
=======
        String bbox_dir_pth;
        String pose_dir_path;
        CameraIntrinsics intrinsics;
@@ -49,7 +38,6 @@ public class ObjectDetector {
            pose_dir_path = "src/main/java/vslam/imperial_london/CameraPoses";
            intrinsics = new CameraIntrinsics("src/main/java/vslam/imperial_london/CameraIntrinsics.csv");
            pointCloud = Downsampler.get_voxels("src/main/java/vslam/imperial_london/pointcloud.csv", 0.05F);
>>>>>>> d54dedd1dda103cf3c9918bc5acfe073621f5ebb
        }

        // get files
@@ -63,20 +51,6 @@ public class ObjectDetector {
        /* #################################################
        In the section below, we create a new ObjectSet, and iterate over each Keyframe
         ################################################## */
<<<<<<< HEAD
        CameraIntrinsics intrinsics = new CameraIntrinsics("src/main/java/vslam/CameraIntrinsics.csv");
        List<Point> pointCloud = Downsampler.get_voxels("src/main/java/vslam/pointcloud.csv", 0.05F);

        if(dataset.equals("1")){
            intrinsics = new CameraIntrinsics("src/main/java/vslam/tum_rgbd/CameraIntrinsics.csv");
            pointCloud = Downsampler.get_voxels("src/main/java/vslam/tum_rgbd/pointcloud.csv", 0.05F);
        } else if(dataset.equals("2")){
            intrinsics = new CameraIntrinsics("src/main/java/vslam/imperial_london/CameraIntrinsicsTUM.csv");
            pointCloud = Downsampler.get_voxels("src/main/java/vslam/imperial_london/pointcloudTUM.csv", 0.05F);
        }

=======
>>>>>>> d54dedd1dda103cf3c9918bc5acfe073621f5ebb
        ObjectSet os = new ObjectSet(intrinsics, pointCloud);

        // iterate through each frame, create the frame, then process it
@@ -113,12 +87,4 @@ public class ObjectDetector {

        return f_arr;
    }

<<<<<<< HEAD
    public static void main(String[] args) throws IOException, CsvValidationException {
        startProcess("1");
    }

=======
>>>>>>> d54dedd1dda103cf3c9918bc5acfe073621f5ebb
}
+6 −0
Original line number Diff line number Diff line
@@ -31,6 +31,12 @@ public class Frame {
        ArrayList<BoundingBox2D> res = new ArrayList<>();
        while (scanner.hasNextLine()) {
            String[] line = scanner.nextLine().split(",");
            double confidence = Double.parseDouble(line[1]);
            // only keep boxes with confidence > 88%
            if(confidence < 0.82){
                continue;
            }

            // create the box accordingly
            int x = Integer.parseInt(line[2]);
            int y = Integer.parseInt(line[3]);
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public class ObjectSet {
        // 3) Find all points that fall within each box, add point to candidate objects
        List<PointSet> candidates = new ArrayList<>();
        for(int i = 0; i < f.boxes.size(); i++){
            candidates.add(new PointSet(i));
            candidates.add(new PointSet(i, f.boxes.get(i).predClass));
        }

        for(Map.Entry<Integer, Point2D> entry : projM.entrySet()){
+8 −30
Original line number Diff line number Diff line
@@ -6,11 +6,8 @@ import java.util.*;

public class PointSet {

    static final int NUM_REPS = 10;
    Set<Point> pset;
    Point[] reps;

    Point centroid;
    String predName;

    final int IDX;

@@ -18,14 +15,13 @@ public class PointSet {
     *
     * @param pp : the points that this PointSet will contain
     */
    public PointSet(int id, Point ...pp){
        pset = new HashSet<>();
    public PointSet(int id, String predName, Point ...pp){
        this.pset = new HashSet<>();

        // add every point blankly to pointset
        pset.addAll(Arrays.asList(pp));
        centroid = new Point(0,0,0);
        reps = new Point[NUM_REPS];
        IDX = id;
        this.pset.addAll(Arrays.asList(pp));
        this.IDX = id;
        this.predName = predName;
    }

    public void addPoint(Point p){
@@ -40,8 +36,8 @@ public class PointSet {
        pset.addAll(p);
    }

    public Point[] getSetReps(){
        return this.reps;
    public String getPred(){
        return this.predName;
    }

    /*
@@ -58,24 +54,6 @@ public class PointSet {
        return res;
    }

    /**
     * This method is called on a specific Point, and updates the Point via
     * some disjoint sets' method.
     */
    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++){

            // early exit if we have less than NUM_REPS points in the current object
            if(i == this.pset.size()) {
                return;
            }

            reps[i] = iter.next();
        }
    }

    public int getIDX() {
        return this.IDX;
    }
Loading