大佬教程收集整理的这篇文章主要介绍了如何降低Android,java上的传感器敏感度?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个很好的类CustomSensorEventListener(见下文)
所有数据,如方位角,民意调查,投球,我得到的正确.
我在屏幕上有单个图像,根据传感器方向移动.
然而,传感器太敏感,我的意思是在任何纳米变化,我的图像略有移动.
像颤抖的东西.如何降低传感器级别,使其像Android上的相机一样.
如您所知,相机在任何传感器更换时都不会颤抖.
谢谢,
public class CustomSensorEventListener implements SensorEventListener { float[] inR = new float[16]; float[] I = new float[16]; float[] gravity = new float[3]; float[] geomag = new float[3]; float[] orientVals = new float[3]; public static double azimuth = 0; public static double pitch = 0; static double roll = 0; private Display mDisplay; public CustomSensorEventListener(Display display){ mDisplay = display; } @Override public void onAccuracyChanged(Sensor sensor,int accuracy) { // TODO Auto-generated method stub } @Override public void onSensorChanged(SensorEvent sensorEvent) { // If the sensor data is unreliable return if (sensorEvent.accuracy == SensoRMANager.SENSOR_STATUS_UNRELIABLE) return; // Gets the value of the sensor that has been changed switch (sensorEvent.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: gravity = sensorEvent.values.clone(); break; case Sensor.TYPE_MAGNETIC_FIELD: geomag = sensorEvent.values.clone(); break; } // If gravity and geomag have values then find rotation matrix if (gravity != null && geomag != null) { // checks that the rotation matrix is found Boolean success = SensoRMANager.getRotationMatrix(inR,I,gravity,geomag); float[] outR = new float[16]; if (success) { SensoRMANager.remapCoordinateSystem(inR,SensoRMANager.AXIS_Y,SensoRMANager.AXIS_MINUS_Z,outR); // Display display = mContext.getWindowManager().getDefaultDisplay(); int deviceRot = mDisplay.getRotation(); switch (deviceRot) { // porTrait - normal case Surface.ROTATION_0: SensoRMANager.remapCoordinateSystem(inR,SensoRMANager.AXIS_X,SensoRMANager.AXIS_Z,outR); break; // rotated left (landscape - keys to bottom) case Surface.ROTATION_90: SensoRMANager.remapCoordinateSystem(inR,SensoRMANager.AXIS_MINUS_X,outR); break; // upside down case Surface.ROTATION_180: SensoRMANager.remapCoordinateSystem(inR,outR); break; // rotated right case Surface.ROTATION_270: SensoRMANager.remapCoordinateSystem(inR,outR); break; default: break; } SensoRMANager.getOrientation(outR,orientVals); azimuth = Math.todegrees(orientVals[0]); pitch = Math.todegrees(orientVals[1]); roll = Math.todegrees(orientVals[2]); } //Log.v("MA","Az: "+azimuth+",Pi: "+pitch+",Ro: "+roll); } } };@H_301_4@
更多信息和实施细节:Low-Pass-Filter-To-Android-Sensors
Smoothing Sensor Data with a Low-Pass Filter
有关低通滤波器的更多信息(维基百科):Low-pass filter
@H_301_4@ @H_301_4@以上是大佬教程为你收集整理的如何降低Android,java上的传感器敏感度?全部内容,希望文章能够帮你解决如何降低Android,java上的传感器敏感度?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。