如何将运动传感器数据从 iPhone 转换为 Android?

发布于 2024-09-14 08:01:50 字数 563 浏览 3 评论 0原文

我有一些用 iPhone 录制的运动传感器样本。 现在我要计算用户手势与 Iphone 上记录的手势之间的距离。

我的问题是,iPhone 上的传感器数据的表示方式与 Android 传感器数据的表示方式不同。如果我不移动 Iphone,我会得到 -1 到 1 之间的数据;如果我不移动 Android 设备,我会得到 9 左右的值,因为传感器测量重力。

我不知道如何转换 Iphone 传感器读数以将它们与我的 Android 传感器读数进行比较。 Android 运动传感器数据在此处进行了解释。 Iphone 文档包含此 pdf

I have some motion sensor samples that were recorded with an Iphone.
Now I'm into calculating a distance between a user gesture and the gesture that was recorded on the Iphone.

My problem is that the sensor data on the Iphone is represented in a different way then the android sensor data. If i don't move the Iphone I get data between -1 and 1 if I don't move my Android device I get values around 9 because the sensor measures the force of gravity.

I couldn't figure out how to convert the Iphone sensor reading to compare them to my android sensor readings. The android motion sensor data is explained here. And the Iphone documentation contains this pdf.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三五鸿雁 2024-09-21 08:01:50

我在将 iPhone 应用程序移植到 Android 时发现了同样的问题。我找到了一个解决方案。这对我的应用程序有用。

  1. 我发现iPhone的加速度计值在-2.5到+2.5之间。
    https://discussions.apple.com/thread/1743220?start= 0&tstart=0
  2. 我发现Android的Sensor Class有找到最大值的方法。
    http://developer.android.com/reference/android/ hardware/Sensor.html#getMaximumRange()

现在我进行简单的计算,如下所示

public void onSensorChanged(SensorEvent event) {
        float t = 2.5f / accMaxValue;
        Log.i(TAG,"onSensorChanged X "+ (event.values[0]*t) +"\t\t Y "+ (event.values[1]*t)+"\t\t Z "+ (event.values[2]*t) );
    }

从传感器获取最大值

    mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    accMaxValue = mAccelerometer.getMaximumRange();

I found same problem while porting iPhone application in Android. I found one solution. It's work for my application.

  1. I found that iPhone's accelerometer value is between -2.5 and +2.5.
    https://discussions.apple.com/thread/1743220?start=0&tstart=0
  2. I found that Android's Sensor Class has method to find max value.
    http://developer.android.com/reference/android/hardware/Sensor.html#getMaximumRange()

Now I put simple calculation like following

public void onSensorChanged(SensorEvent event) {
        float t = 2.5f / accMaxValue;
        Log.i(TAG,"onSensorChanged X "+ (event.values[0]*t) +"\t\t Y "+ (event.values[1]*t)+"\t\t Z "+ (event.values[2]*t) );
    }

Get Max value from Sensor

    mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    accMaxValue = mAccelerometer.getMaximumRange();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文