public void add(Gesture gesture) { if (gesture.getId() == null) { gesture.setId(curId); gestures.put(curId, gesture); curId++; } else { gestures.put(gesture.getId(), gesture); } }
public void addGestureTrace(String id, ArrayList<float[]> trace, boolean addToDB) { /* * reads a gesture id and a trace and then adds it to * gesture hashmap and optionally saves it to the DB */ Gesture g = new Gesture(); g.databaseID = -1; /* not known to database yet */ g.gestureTrace = trace; g.gestureID = id; g.gestureAdded = System.currentTimeMillis(); this.addGesture(id, g, addToDB); }
public void setGesture(Gesture gesture) { if (gesture == null) { throw new DaoException( "To-one property 'gesture_id' has not-null constraint; cannot set to-one to null"); } synchronized (this) { this.gesture = gesture; gesture_id = gesture.getId(); gesture__resolvedKey = gesture_id; } }
// Read coordinate data from stdin static void read_input(Gesture g) throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); String line; while ((line = stdin.readLine()) != null) { String[] field = line.split("[ \t]+"); double[] point = new double[3]; for (int i = 0; i < 3; i++) point[i] = Double.parseDouble(field[i]); // System.out.println("Input coordinate " + point[0] + ", " + point[1] + ", " + point[2]); g.add(point); } return; }
// Find the min and max values static void normalize_input(Gesture g) { double maxacc = Double.MIN_VALUE; double minacc = Double.MAX_VALUE; for (int i = 0; i < g.getData().size(); i++) { for (int coord = 0; coord < 3; coord++) { if (Math.abs(g.getData().elementAt(i)[coord]) > maxacc) maxacc = Math.abs(g.getData().elementAt(i)[coord]); if (Math.abs(g.getData().elementAt(i)[coord]) < minacc) minacc = Math.abs(g.getData().elementAt(i)[coord]); } } g.setMaxAcceleration(maxacc); g.setMinAcceleration(minacc); // System.out.printf("minacc %f, maxacc %f\n", minacc, maxacc); return; }
public void set(int id, Gesture gesture) { gesture.setId(id); gestures.put(id, gesture); }
public void remove(Gesture gesture) { gestures.remove(gesture.getId()); }
private void classify(GestureData gestureData) throws Exception { TimeSeries timeSeries = Utils.dataToTimeSeries(gestureData.getValues()); Gesture gesture = Classifier.getInstance().knn(1, timeSeries); System.out.println(gesture); Keyboard.getInstance().type(gesture.getCommand()); }