Back to project page Cam2IMU_calib.
The source code is released under:
MIT License
If you think the Android project Cam2IMU_calib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package cvg.vslam.c2i_calib; //from ww w. java 2s .c o m import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import java.util.ArrayDeque; import java.util.Deque; /** * Created with IntelliJ IDEA. * User: fede * Date: 7/17/13 * Time: 5:38 PM * To change this template use File | Settings | File Templates. */ public class SensorBuffer implements SensorEventListener { private SensorManager sensorManager; // private final Context context; private Deque<SensorEvent> buffer; private static final int buffSize = 10; public SensorBuffer(Context context) { // this.context = context; sensorManager = (SensorManager) context.getSystemService(context.SENSOR_SERVICE); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME); buffer = new ArrayDeque<SensorEvent>(); } @Override public void onSensorChanged(SensorEvent event){ if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){ buffer.add(event); if (buffer.size() > buffSize){ buffer.removeLast(); } } } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { // NOP } public String getBufferAt(long timeStamp){ return String.valueOf(buffer.size()); } }