Commit c7c03df6 authored by Rohan  Kumar's avatar Rohan Kumar
Browse files

"push"

parent a65e99be
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
package vslam.object_detection;
package object_detection;

public class ObjectDetector {
    static ObjectSet os;
@@ -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){
+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<>();
    }
@@ -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;
    }

    /**
@@ -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++;
            }
        }
+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 {

+6 −7
Original line number Diff line number Diff line
package vslam.object_detection;
package object_detection;

import java.util.*;

@@ -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){
@@ -36,7 +33,7 @@ public class PointSet {
    }

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

    public List<Point> getPoints(){
@@ -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();
        }
    }