public class Persons{ private final int DISTANZE_NO_MOVE =10; private final int DISTANZE_SAME_PERSON = 200; private final int FRAMES_BEFORE_DELETE = 10; public class Person{ public int x; public int y; public int framesSinceLastSeen; public boolean matched = false; public int matched_id; public Person(int x, int y){ this.x = x; this.y = y; this.framesSinceLastSeen = 0; } } public ArrayList persons = new ArrayList(); public Persons(){ } public void calculatePersonPositions(int[] personsX, int[] personsY){ boolean matched[] = new boolean[personsX.length]; for (int j=0;j personsToRemove = new ArrayList(); for (Person p : persons){ if(p.matched){ float d = dist( p.x, p.y, personsX[p.matched_id], personsY[p.matched_id]); if(d > DISTANZE_NO_MOVE) { p.x = personsX[p.matched_id]; p.y = personsY[p.matched_id]; p.framesSinceLastSeen = 0; } }else{ p.framesSinceLastSeen ++; if( p.framesSinceLastSeen > this.FRAMES_BEFORE_DELETE){ personsToRemove.add(p); } } } //remove Persons not seen for too long for (Person p : personsToRemove){ persons.remove(p); } //create new Persons for deteced Persons, that were not matched for (int i=0;i