How to convert motion sensor data from iPhone to Android?

I have samples of motion sensors that were recorded using an iPhone. Now I calculate the distance between the user's gesture and the gesture recorded on the Iphone.

My problem is that the sensor data on the Iphone is presented differently than the android sensor data. If I do not move Iphone, I get data between -1 and 1, if I do not move my Android device. I get values ​​around 9 because the sensor measures gravity.

I could not figure out how to convert the Iphone sensor readings to compare them with the sensor readings. Android motion sensor data is explained here . And the Iphone documentation contains this pdf .

+3
source share
1 answer

I found the same problem when porting an iPhone application to Android. I found one solution. It works for my application. Hope this helps you.

Now I put a simple calculation as follows

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 the maximum value from the sensor

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

Hope this helps ...

+2
source

Source: https://habr.com/ru/post/1759102/


All Articles