Commit 2177ed6c authored by Rohan  Kumar's avatar Rohan Kumar
Browse files

"adding boundingbox class"

parent 8dd543fe
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
package object_detection;

import object_detection.types.ObjectSet;
import object_detection.types.Point;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class ObjectDetector {
@@ -9,10 +14,25 @@ public class ObjectDetector {
    static ObjectSet os;

    public static void run() throws IOException {
        System.out.println("Running object detection");
        System.out.println("Running object detection:");
        ObjectDetector.main(null);
    }

    public static void processFrame(String framename) throws FileNotFoundException {
        // 1) we get the feature points, store as an
        Scanner sc = new Scanner(new File(framename));
        sc.useDelimiter("\n");

        // 2) we map each point to an object using the bounding boxes
        double[][] box1 = {{1, 2}, {3, 4}};

        System.out.println(Arrays.deepToString(box1));

        // 3)


    }

    public static void main(String[] args) throws IOException {

        /* infinite loop of running system:
@@ -24,14 +44,7 @@ public class ObjectDetector {
        // create objectset
        os = new ObjectSet();

        // get data from keyframe
        Scanner sc = new Scanner(new File("src/main/java/vslam/KeyFramePoints/KeyFramePoints_0003.csv"));
        sc.useDelimiter("\n");

        while(sc.hasNext()){
            System.out.println(sc.next());
        }
        sc.close();
        processFrame("src/main/java/vslam/KeyFramePoints/KeyFramePoints_0003.csv");

        // Add two test sets
        int o1 = os.makeObject(
+27 −0
Original line number Diff line number Diff line
package object_detection.types;

public class BoundingBox {

    public BoundingBox(Point2D tr, Point2D tl, Point2D br, Point2D bl){
        this.topRight = tr;
        this.topLeft = tl;
        this.botRight = br;
        this.botLeft = bl;
    }

    public boolean within(Point2D p){
        return p.getX() < this.topRight.getX()
                && p.getX() > this.topLeft.getX()
                && p.getY() < this.topLeft.getY()
                && p.getY() > this.botLeft.getY();
    }


    // members
    Point2D topRight;
    Point2D topLeft;
    Point2D botRight;
    Point2D botLeft;


}
+3 −3
Original line number Diff line number Diff line
package object_detection;
package object_detection.types;

import java.util.*;

public class ObjectSet {

    static List<PointSet> objects;
    public static List<PointSet> objects;
    static int count = 0;
    public ObjectSet(){
        objects = new ArrayList<>();
+12 −1
Original line number Diff line number Diff line
package object_detection;
package object_detection.types;

public class Point {

@@ -53,4 +53,15 @@ public class Point {
        return "Point(" + this.x + " ," + this.y + " ," + this.z + ")";
    }

    public float getY() {
        return y;
    }

    public float getX() {
        return x;
    }

    public float getZ() {
        return z;
    }
}
+20 −0
Original line number Diff line number Diff line
package object_detection.types;

public class Point2D {

    private float x;
    private float y;

    public Point2D(float x, float y){
        this.x = x;
        this.y = y;
    }

    public float getY() {
        return y;
    }

    public float getX() {
        return x;
    }
}
Loading