Moved InfraredEvent. Divided DeviceListenerInterface to ButtonListener and AccelerationListener. Added RotationListener for basic Wii Motion Plus support (isn't used for gesture recognition yet), but readout works. wiigee is one of the first libs to support the wii motion plus. Thanks to anyone, who contributed to find out the initialization procedure (wiibrew-wiki, cwiid).
git-svn-id: svn://svn.code.sf.net/p/wiigee/code/trunk@93 c7eff9ee-dd40-0410-8832-91a4d88773cf
This commit is contained in:
@@ -33,7 +33,7 @@ import org.wiigee.util.Log;
|
|||||||
public class Wiigee {
|
public class Wiigee {
|
||||||
|
|
||||||
protected static String version = "1.5 alpha";
|
protected static String version = "1.5 alpha";
|
||||||
protected static String releasedate = "20090605";
|
protected static String releasedate = "20090617";
|
||||||
|
|
||||||
protected Wiigee() {
|
protected Wiigee() {
|
||||||
Log.write("This is wiigee version "+version+" ("+releasedate+")");
|
Log.write("This is wiigee version "+version+" ("+releasedate+")");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* wiigee - accelerometerbased gesture recognition
|
* wiigee - accelerometerbased gesture recognition
|
||||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||||
*
|
*
|
||||||
* Developed at University of Oldenburg
|
* Developed at University of Oldenburg
|
||||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||||
@@ -45,17 +45,19 @@ public class Device {
|
|||||||
protected boolean accelerationenabled;
|
protected boolean accelerationenabled;
|
||||||
|
|
||||||
// Filters, can filter the data stream
|
// Filters, can filter the data stream
|
||||||
protected Vector<Filter> filters = new Vector<Filter>();
|
protected Vector<Filter> accfilters = new Vector<Filter>();
|
||||||
|
|
||||||
// Listeners, receive generated events
|
// Listeners, receive generated events
|
||||||
protected Vector<DeviceListener> devicelistener = new Vector<DeviceListener>();
|
protected Vector<AccelerationListener> accelerationlistener = new Vector<AccelerationListener>();
|
||||||
|
protected Vector<ButtonListener> buttonlistener = new Vector<ButtonListener>();
|
||||||
protected ProcessingUnit processingunit = new TriggeredProcessingUnit();
|
protected ProcessingUnit processingunit = new TriggeredProcessingUnit();
|
||||||
|
|
||||||
public Device() {
|
public Device() {
|
||||||
this.addFilter(new IdleStateFilter());
|
this.addFilter(new IdleStateFilter());
|
||||||
this.addFilter(new MotionDetectFilter(this));
|
this.addFilter(new MotionDetectFilter(this));
|
||||||
this.addFilter(new DirectionalEquivalenceFilter());
|
this.addFilter(new DirectionalEquivalenceFilter());
|
||||||
this.addDeviceListener(this.processingunit);
|
this.addAccelerationListener(this.processingunit);
|
||||||
|
this.addButtonListener(this.processingunit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,31 +65,35 @@ public class Device {
|
|||||||
* @param filter The Filter instance.
|
* @param filter The Filter instance.
|
||||||
*/
|
*/
|
||||||
public void addFilter(Filter filter) {
|
public void addFilter(Filter filter) {
|
||||||
this.filters.add(filter);
|
this.accfilters.add(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets all the filters, which are resetable.
|
* Resets all the accfilters, which are resetable.
|
||||||
* Sometimes they have to be resettet if a new gesture starts.
|
* Sometimes they have to be resettet if a new gesture starts.
|
||||||
*/
|
*/
|
||||||
public void resetFilters() {
|
public void resetFilters() {
|
||||||
for(int i=0; i<this.filters.size(); i++) {
|
for(int i=0; i<this.accfilters.size(); i++) {
|
||||||
this.filters.elementAt(i).reset();
|
this.accfilters.elementAt(i).reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an WiimoteListener to the wiimote. Everytime an action
|
* Adds an AccelerationListener to the Device. Everytime an acceleration
|
||||||
* on the wiimote is performed the WiimoteListener would receive
|
* on the Device is performed the AccelerationListener would receive
|
||||||
* an event of this action.
|
* an event of this action.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void addDeviceListener(DeviceListener listener) {
|
public void addAccelerationListener(AccelerationListener listener) {
|
||||||
this.devicelistener.add(listener);
|
this.accelerationlistener.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addButtonListener(ButtonListener listener) {
|
||||||
|
this.buttonlistener.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a GestureListener to the wiimote. Everytime a gesture
|
* Adds a GestureListener to the Device. Everytime a gesture
|
||||||
* is performed the GestureListener would receive an event of
|
* is performed the GestureListener would receive an event of
|
||||||
* this gesture.
|
* this gesture.
|
||||||
*/
|
*/
|
||||||
@@ -146,17 +152,13 @@ public class Device {
|
|||||||
// ###### Event-Methoden
|
// ###### Event-Methoden
|
||||||
|
|
||||||
/** Fires an acceleration event.
|
/** Fires an acceleration event.
|
||||||
* @param x
|
* @param vector Consists of three values:
|
||||||
* Acceleration in x direction
|
* acceleration on X, Y and Z axis.
|
||||||
* @param y
|
|
||||||
* Acceleration in y direction
|
|
||||||
* @param z
|
|
||||||
* Acceleration in z direction
|
|
||||||
*/
|
*/
|
||||||
public void fireAccelerationEvent(double[] vector) {
|
public void fireAccelerationEvent(double[] vector) {
|
||||||
for(int i=0; i<this.filters.size(); i++) {
|
for(int i=0; i<this.accfilters.size(); i++) {
|
||||||
vector = this.filters.get(i).filter(vector);
|
vector = this.accfilters.get(i).filter(vector);
|
||||||
// cannot return here if null, because of time-dependent filters
|
// cannot return here if null, because of time-dependent accfilters
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't need to create an event if filtered away
|
// don't need to create an event if filtered away
|
||||||
@@ -167,8 +169,8 @@ public class Device {
|
|||||||
|
|
||||||
AccelerationEvent w = new AccelerationEvent(this,
|
AccelerationEvent w = new AccelerationEvent(this,
|
||||||
vector[0], vector[1], vector[2], absvalue);
|
vector[0], vector[1], vector[2], absvalue);
|
||||||
for(int i=0; i<this.devicelistener.size(); i++) {
|
for(int i=0; i<this.accelerationlistener.size(); i++) {
|
||||||
this.devicelistener.get(i).accelerationReceived(w);
|
this.accelerationlistener.get(i).accelerationReceived(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,8 +182,8 @@ public class Device {
|
|||||||
*/
|
*/
|
||||||
public void fireButtonPressedEvent(int button) {
|
public void fireButtonPressedEvent(int button) {
|
||||||
ButtonPressedEvent w = new ButtonPressedEvent(this, button);
|
ButtonPressedEvent w = new ButtonPressedEvent(this, button);
|
||||||
for(int i=0; i<this.devicelistener.size(); i++) {
|
for(int i=0; i<this.buttonlistener.size(); i++) {
|
||||||
this.devicelistener.get(i).buttonPressReceived(w);
|
this.buttonlistener.get(i).buttonPressReceived(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(w.isRecognitionInitEvent() || w.isTrainInitEvent()) {
|
if(w.isRecognitionInitEvent() || w.isTrainInitEvent()) {
|
||||||
@@ -193,8 +195,8 @@ public class Device {
|
|||||||
*/
|
*/
|
||||||
public void fireButtonReleasedEvent() {
|
public void fireButtonReleasedEvent() {
|
||||||
ButtonReleasedEvent w = new ButtonReleasedEvent(this);
|
ButtonReleasedEvent w = new ButtonReleasedEvent(this);
|
||||||
for(int i=0; i<this.devicelistener.size(); i++) {
|
for(int i=0; i<this.buttonlistener.size(); i++) {
|
||||||
this.devicelistener.get(i).buttonReleaseReceived(w);
|
this.buttonlistener.get(i).buttonReleaseReceived(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +205,8 @@ public class Device {
|
|||||||
*/
|
*/
|
||||||
public void fireMotionStartEvent() {
|
public void fireMotionStartEvent() {
|
||||||
MotionStartEvent w = new MotionStartEvent(this);
|
MotionStartEvent w = new MotionStartEvent(this);
|
||||||
for(int i=0; i<this.devicelistener.size(); i++) {
|
for(int i=0; i<this.accelerationlistener.size(); i++) {
|
||||||
this.devicelistener.get(i).motionStartReceived(w);
|
this.accelerationlistener.get(i).motionStartReceived(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,8 +215,8 @@ public class Device {
|
|||||||
*/
|
*/
|
||||||
public void fireMotionStopEvent() {
|
public void fireMotionStopEvent() {
|
||||||
MotionStopEvent w = new MotionStopEvent(this);
|
MotionStopEvent w = new MotionStopEvent(this);
|
||||||
for(int i=0; i<this.devicelistener.size(); i++) {
|
for(int i=0; i<this.accelerationlistener.size(); i++) {
|
||||||
this.devicelistener.get(i).motionStopReceived(w);
|
this.accelerationlistener.get(i).motionStopReceived(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* wiigee - accelerometerbased gesture recognition
|
* wiigee - accelerometerbased gesture recognition
|
||||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||||
*
|
*
|
||||||
* Developed at University of Oldenburg
|
* Developed at University of Oldenburg
|
||||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||||
@@ -32,7 +32,7 @@ import org.wiigee.device.*;
|
|||||||
* This Event would be generated if an acceleration has been detected.
|
* This Event would be generated if an acceleration has been detected.
|
||||||
* It contains information about the force applied to the device in each
|
* It contains information about the force applied to the device in each
|
||||||
* direction (x, y, z). Further it contains the absolute value of this
|
* direction (x, y, z). Further it contains the absolute value of this
|
||||||
* vector and the source which generated this event (wiimote).
|
* vector and the source which generated this event (Device).
|
||||||
*
|
*
|
||||||
* @author Benjamin 'BePo' Poppinga
|
* @author Benjamin 'BePo' Poppinga
|
||||||
*
|
*
|
||||||
@@ -41,10 +41,9 @@ public class AccelerationEvent extends EventObject {
|
|||||||
|
|
||||||
double X, Y, Z;
|
double X, Y, Z;
|
||||||
double absvalue;
|
double absvalue;
|
||||||
Device source;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WiimoteAccelerationEvent with a specific source,
|
* Create an AccelerationEvent with a specific source,
|
||||||
* all the three acceleration values and the calculated absolute
|
* all the three acceleration values and the calculated absolute
|
||||||
* value.
|
* value.
|
||||||
*
|
*
|
||||||
@@ -56,17 +55,12 @@ public class AccelerationEvent extends EventObject {
|
|||||||
*/
|
*/
|
||||||
public AccelerationEvent(Device source, double X, double Y, double Z, double absvalue) {
|
public AccelerationEvent(Device source, double X, double Y, double Z, double absvalue) {
|
||||||
super(source);
|
super(source);
|
||||||
this.source=source;
|
|
||||||
this.X=X;
|
this.X=X;
|
||||||
this.Y=Y;
|
this.Y=Y;
|
||||||
this.Z=Z;
|
this.Z=Z;
|
||||||
this.absvalue=absvalue;
|
this.absvalue=absvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Device getSource() {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return X;
|
return X;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* wiigee - accelerometerbased gesture recognition
|
* wiigee - accelerometerbased gesture recognition
|
||||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||||
*
|
*
|
||||||
* Developed at University of Oldenburg
|
* Developed at University of Oldenburg
|
||||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||||
@@ -28,40 +28,24 @@ import java.util.EventListener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface has to be implemented if the application should react
|
* This interface has to be implemented if the application should react
|
||||||
* to pure acceleration data or button press/release. This could be
|
* to pure acceleration data. This could be useful if you want to e.g.
|
||||||
* useful if you want to graphically display the acceleration data or
|
* graphically display the acceleration data in your application.
|
||||||
* something else in your application.
|
|
||||||
*
|
*
|
||||||
* @author Benjamin 'BePo' Poppinga
|
* @author Benjamin 'BePo' Poppinga
|
||||||
*/
|
*/
|
||||||
public interface DeviceListener extends EventListener {
|
public interface AccelerationListener extends EventListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method would be called if a Wiimote source has been accelerated.
|
* This method would be called if a Device source has been accelerated.
|
||||||
*
|
*
|
||||||
* @param event The acceleration representation as an event.
|
* @param event The acceleration representation as an event.
|
||||||
*/
|
*/
|
||||||
public abstract void accelerationReceived(AccelerationEvent event);
|
public abstract void accelerationReceived(AccelerationEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method would be called if a Wiimote button has been pressed.
|
* This method would be called if a Device is in idle state and then a
|
||||||
*
|
* motion starts or if a Device is in motion and then the motion stops and
|
||||||
* @param event The button representation as an event.
|
* the Device is in idle state.
|
||||||
*/
|
|
||||||
public abstract void buttonPressReceived(ButtonPressedEvent event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method would be called if a Wiimote button has been released.
|
|
||||||
*
|
|
||||||
* @param event This is actually a meta-event NOT containing which button
|
|
||||||
* has been released.
|
|
||||||
*/
|
|
||||||
public abstract void buttonReleaseReceived(ButtonReleasedEvent event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method would be called if a Wiimote is in idle state and then a
|
|
||||||
* motion starts or if a Wiimote is in motion and then the motion stops and
|
|
||||||
* the Wiimote is in idle state.
|
|
||||||
*
|
*
|
||||||
* @param event This is the event which contains if the Wiimote is now
|
* @param event This is the event which contains if the Wiimote is now
|
||||||
* in motion or not.
|
* in motion or not.
|
||||||
@@ -69,15 +53,13 @@ public interface DeviceListener extends EventListener {
|
|||||||
public abstract void motionStartReceived(MotionStartEvent event);
|
public abstract void motionStartReceived(MotionStartEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method would be called if a Wiimote is in motion and then the motion
|
* This method would be called if a Device is in motion and then the motion
|
||||||
* stops and the Wiimote is in idle state.
|
* stops and the Device is in idle state.
|
||||||
*
|
*
|
||||||
* @param event This is the event which contains if the Wiimote is now
|
* @param event This is the event which contains if the Device is now
|
||||||
* in motion or not.
|
* in motion or not.
|
||||||
*/
|
*/
|
||||||
public abstract void motionStopReceived(MotionStopEvent event);
|
public abstract void motionStopReceived(MotionStopEvent event);
|
||||||
|
|
||||||
public abstract void infraredReceived(InfraredEvent event);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
53
src/org/wiigee/event/InfraredEvent.java → src/org/wiigee/event/ButtonListener.java
Executable file → Normal file
53
src/org/wiigee/event/InfraredEvent.java → src/org/wiigee/event/ButtonListener.java
Executable file → Normal file
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* wiigee - accelerometerbased gesture recognition
|
* wiigee - accelerometerbased gesture recognition
|
||||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||||
*
|
*
|
||||||
* Developed at University of Oldenburg
|
* Developed at University of Oldenburg
|
||||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||||
@@ -24,40 +24,31 @@
|
|||||||
|
|
||||||
package org.wiigee.event;
|
package org.wiigee.event;
|
||||||
|
|
||||||
import java.util.EventObject;
|
import java.util.EventListener;
|
||||||
import org.wiigee.device.Device;
|
|
||||||
|
|
||||||
public class InfraredEvent extends EventObject {
|
/**
|
||||||
|
* This interface has to be implemented if the application should react
|
||||||
|
* to button press/releases.
|
||||||
|
*
|
||||||
|
* @author Benjamin 'BePo' Poppinga
|
||||||
|
*/
|
||||||
|
public interface ButtonListener extends EventListener {
|
||||||
|
|
||||||
protected Device wiimote;
|
|
||||||
protected int[][] coordinates;
|
|
||||||
protected int[] size;
|
|
||||||
protected boolean[] valid;
|
|
||||||
|
|
||||||
public InfraredEvent(Device source, int[][] coordinates, int[] size) {
|
/**
|
||||||
super(source);
|
* This method would be called if a Device button has been pressed.
|
||||||
this.coordinates=coordinates;
|
*
|
||||||
this.size=size;
|
* @param event The button representation as an event.
|
||||||
this.valid = new boolean[4];
|
*/
|
||||||
for(int i=0; i<this.coordinates.length; i++) {
|
public abstract void buttonPressReceived(ButtonPressedEvent event);
|
||||||
this.valid[i] = (this.coordinates[i][0]<1023 && this.coordinates[i][1]<1023);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Device getSource() {
|
/**
|
||||||
return this.wiimote;
|
* This method would be called if a Device button has been released.
|
||||||
}
|
*
|
||||||
|
* @param event This is actually a meta-event NOT containing which button
|
||||||
|
* has been released.
|
||||||
|
*/
|
||||||
|
public abstract void buttonReleaseReceived(ButtonReleasedEvent event);
|
||||||
|
|
||||||
public boolean isValid(int i) {
|
|
||||||
return this.valid[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[][] getCoordinates() {
|
|
||||||
return this.coordinates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getSize() {
|
|
||||||
return this.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,14 +26,6 @@ package org.wiigee.filter;
|
|||||||
|
|
||||||
public abstract class Filter {
|
public abstract class Filter {
|
||||||
|
|
||||||
public Filter() {
|
|
||||||
// nothing, but should be called via SUPER.
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
// reset filter, if necessary.
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* The actual called method to filter anything. It checks if the vector is
|
* The actual called method to filter anything. It checks if the vector is
|
||||||
* already set to NULL by another filter and won't process it anymore. If it's
|
* already set to NULL by another filter and won't process it anymore. If it's
|
||||||
@@ -60,4 +52,6 @@ public abstract class Filter {
|
|||||||
*/
|
*/
|
||||||
abstract public double[] filterAlgorithm(double[] vector);
|
abstract public double[] filterAlgorithm(double[] vector);
|
||||||
|
|
||||||
|
abstract public void reset();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,12 +40,17 @@ public class HighPassFilter extends Filter {
|
|||||||
public HighPassFilter() {
|
public HighPassFilter() {
|
||||||
super();
|
super();
|
||||||
this.factor = 0.1;
|
this.factor = 0.1;
|
||||||
this.prevAcc = new double[] {0.0, 0.0, 0.0};
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HighPassFilter(double factor) {
|
public HighPassFilter(double factor) {
|
||||||
super();
|
super();
|
||||||
this.factor = factor;
|
this.factor = factor;
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
this.prevAcc = new double[] {0.0, 0.0, 0.0};
|
this.prevAcc = new double[] {0.0, 0.0, 0.0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ public class IdleStateFilter extends Filter {
|
|||||||
this.sensivity = 0.1;
|
this.sensivity = 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
// not needed
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double[] filterAlgorithm(double[] vector) {
|
public double[] filterAlgorithm(double[] vector) {
|
||||||
// calculate values needed for filtering:
|
// calculate values needed for filtering:
|
||||||
// absolute value
|
// absolute value
|
||||||
|
|||||||
@@ -40,12 +40,17 @@ public class LowPassFilter extends Filter {
|
|||||||
public LowPassFilter() {
|
public LowPassFilter() {
|
||||||
super();
|
super();
|
||||||
this.factor = 0.01;
|
this.factor = 0.01;
|
||||||
this.prevAcc = new double[] {0.0, 0.0, 0.0};
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LowPassFilter(double factor) {
|
public LowPassFilter(double factor) {
|
||||||
super();
|
super();
|
||||||
this.factor = factor;
|
this.factor = factor;
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
this.prevAcc = new double[] {0.0, 0.0, 0.0};
|
this.prevAcc = new double[] {0.0, 0.0, 0.0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,12 +48,12 @@ public class MotionDetectFilter extends Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
super.reset();
|
|
||||||
this.motionstartstamp=System.currentTimeMillis();
|
this.motionstartstamp=System.currentTimeMillis();
|
||||||
this.nowinmotion=false;
|
this.nowinmotion=false;
|
||||||
this.motionchangetime=190;
|
this.motionchangetime=190;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double[] filter(double[] vector) {
|
public double[] filter(double[] vector) {
|
||||||
|
|
||||||
if(this.nowinmotion &&
|
if(this.nowinmotion &&
|
||||||
|
|||||||
@@ -5,16 +5,16 @@ import java.util.Vector;
|
|||||||
import org.wiigee.event.AccelerationEvent;
|
import org.wiigee.event.AccelerationEvent;
|
||||||
import org.wiigee.event.ButtonPressedEvent;
|
import org.wiigee.event.ButtonPressedEvent;
|
||||||
import org.wiigee.event.ButtonReleasedEvent;
|
import org.wiigee.event.ButtonReleasedEvent;
|
||||||
import org.wiigee.event.DeviceListener;
|
import org.wiigee.event.AccelerationListener;
|
||||||
|
import org.wiigee.event.ButtonListener;
|
||||||
import org.wiigee.event.GestureEvent;
|
import org.wiigee.event.GestureEvent;
|
||||||
import org.wiigee.event.GestureListener;
|
import org.wiigee.event.GestureListener;
|
||||||
import org.wiigee.event.InfraredEvent;
|
|
||||||
import org.wiigee.event.MotionStartEvent;
|
import org.wiigee.event.MotionStartEvent;
|
||||||
import org.wiigee.event.MotionStopEvent;
|
import org.wiigee.event.MotionStopEvent;
|
||||||
import org.wiigee.event.StateEvent;
|
import org.wiigee.event.StateEvent;
|
||||||
import org.wiigee.util.Log;
|
import org.wiigee.util.Log;
|
||||||
|
|
||||||
public abstract class ProcessingUnit implements DeviceListener {
|
public abstract class ProcessingUnit implements AccelerationListener, ButtonListener {
|
||||||
|
|
||||||
// Classifier
|
// Classifier
|
||||||
protected Classifier classifier;
|
protected Classifier classifier;
|
||||||
@@ -57,8 +57,6 @@ public abstract class ProcessingUnit implements DeviceListener {
|
|||||||
|
|
||||||
public abstract void buttonReleaseReceived(ButtonReleasedEvent event);
|
public abstract void buttonReleaseReceived(ButtonReleasedEvent event);
|
||||||
|
|
||||||
public abstract void infraredReceived(InfraredEvent event);
|
|
||||||
|
|
||||||
public abstract void motionStartReceived(MotionStartEvent event);
|
public abstract void motionStartReceived(MotionStartEvent event);
|
||||||
|
|
||||||
public abstract void motionStopReceived(MotionStopEvent event);
|
public abstract void motionStopReceived(MotionStopEvent event);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* wiigee - accelerometerbased gesture recognition
|
* wiigee - accelerometerbased gesture recognition
|
||||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||||
*
|
*
|
||||||
* Developed at University of Oldenburg
|
* Developed at University of Oldenburg
|
||||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||||
@@ -29,7 +29,7 @@ import org.wiigee.event.*;
|
|||||||
import org.wiigee.util.Log;
|
import org.wiigee.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class analyzes the WiimoteAccelerationEvents emitted from a Wiimote
|
* This class analyzes the AccelerationEvents emitted from a Wiimote
|
||||||
* and further creates and manages the different models for each type
|
* and further creates and manages the different models for each type
|
||||||
* of gesture.
|
* of gesture.
|
||||||
*
|
*
|
||||||
@@ -82,11 +82,6 @@ public class TriggeredProcessingUnit extends ProcessingUnit {
|
|||||||
this.handleStopEvent(event);
|
this.handleStopEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void infraredReceived(InfraredEvent event) {
|
|
||||||
// NOTHING TO DO HERE
|
|
||||||
}
|
|
||||||
|
|
||||||
public void motionStartReceived(MotionStartEvent event) {
|
public void motionStartReceived(MotionStartEvent event) {
|
||||||
this.handleStartEvent(event);
|
this.handleStartEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user