Skip to content

Commit

Permalink
Merge pull request #37 from opennars/HigherResolution1
Browse files Browse the repository at this point in the history
Higher resolution1
  • Loading branch information
patham9 authored Jul 9, 2019
2 parents 82e0e37 + 58bedda commit f896e03
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
13 changes: 9 additions & 4 deletions src/main/java/org/opennars/applications/crossing/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Entity {
public static int entityID = 0;
public String label = "";
public double posX, posY;
public double width, height;
public double getPosX() {
return posX;
}
Expand All @@ -47,11 +48,8 @@ public double getPosY() {
public float maxSpeed = 2.0f;
public static boolean pedestrianIgnoreTrafficLight = false;
public static boolean carIgnoreTrafficLight = false;

public double normalness = 0.0;

public boolean isPredicted = false;

public double lastPosX = 0;
public double lastPosY = 0;

Expand Down Expand Up @@ -130,7 +128,14 @@ public void draw(PApplet applet, TruthValue truth, long time) {
}
}
if(!isPredicted) {
applet.ellipse(2.5f, 2.5f, Util.discretization*scale, Util.discretization*scale);
//applet.rect((float) (0.0f-width/2.0f), (float) (0.0f-height/2.0f), (float) width, (float) height);
float mul2 = 2.0f;
if(RealCrossing.running) {
applet.ellipse(2.5f, 2.5f, Util.discretization*scale*mul2, Util.discretization*scale*mul2);
} else {
applet.ellipse(2.5f, 2.5f, Util.discretization*scale, Util.discretization*scale);
}

}

if(RealCrossing.running) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ public void draw() {
}
Integer X = Integer.valueOf(unwrap(props[3]));
Integer Y = Integer.valueOf(unwrap(props[4]));

Integer width = Integer.valueOf(unwrap(props[5]));
Integer height = Integer.valueOf(unwrap(props[6]));

Integer X2 = Integer.valueOf(unwrap(props[19])); //7 6
Integer Y2 = Integer.valueOf(unwrap(props[20]));
Expand All @@ -229,26 +232,37 @@ public void draw() {
if(Y < Y2) {
id += 1;
}


double angle = Math.atan2(Y - Y2, X - X2);

double movement = Math.sqrt((X-X2)*(X-X2) + (Y - Y2)*(Y - Y2));
if(props[0].equals("0")) { //person or vehicle for now
if(movement < (double)movementThresholdPedestrian) {
continue;
}
Pedestrian toAdd = new Pedestrian(id, X, Y, 0, 0, label);
Pedestrian toAdd = new Pedestrian(id, X2, Y2, 0, 0, label);
toAdd.width = width;
toAdd.height = height;
//toAdd.angle = angle;
entities.add(toAdd);
} else {
if(!props[0].equals("1")) {
if(movement < (double)movementThresholdCar) {
continue;
}
Car toAdd = new Car(id, X, Y, 0, 0, label);
Car toAdd = new Car(id, X2, Y2, 0, 0, label);
toAdd.width = width;
toAdd.height = height;
//toAdd.angle = angle;
entities.add(toAdd);
} else {
if(movement < (double)movementThresholdBike) {
continue;
}
Bike toAdd = new Bike(id, X, Y, 0, 0, label);
Bike toAdd = new Bike(id, X2, Y2, 0, 0, label);
toAdd.width = width;
toAdd.height = height;
//toAdd.angle = angle;
entities.add(toAdd);
}
}
Expand Down Expand Up @@ -329,7 +343,7 @@ public static void main(String[] args) {
//</editor-fold>
System.out.println("args: videopath trackletpath [discretization movementThreshold]");
System.out.println("example: java -cp \"*\" org.opennars.applications.crossing.RealCrossing /mnt/sda1/Users/patha/Downloads/Test/Test/Test001/ /home/tc/Dateien/CROSSING/Test001/ 100 10");
Util.discretization = 100;
Util.discretization = 50;
if(args.length == 2) {
RealCrossing.videopath = args[0];
RealCrossing.trackletpath = args[1];
Expand Down

0 comments on commit f896e03

Please sign in to comment.