[英]Is there a conversion factor between Android sampling frequency (Hz) and sampling period (µs) (HIGH_SAMPLING_RATE_SENSORS)
I'm retrieving sensor data by using mSensorManager.registerListener(this, mLinearAccelerometer, SAMPLINGPERIOD)
我正在使用mSensorManager.registerListener(this, mLinearAccelerometer, SAMPLINGPERIOD)
检索传感器数据
Android 12 introduced a rate-limitation on sensor data. Android 12 引入了对传感器数据的速率限制。 If you call the registerListener() method, the sensor sampling rate is limited to 200 Hz .如果您调用 registerListener() 方法,传感器采样率被限制为 200 Hz 。 If your app tries to gather motion sensor data at a higher rate without declaring the new permission HIGH_SAMPLING_RATE_SENSORS , a SecurityException occurs.如果您的应用程序尝试以更高的速率收集运动传感器数据而未声明新权限HIGH_SAMPLING_RATE_SENSORS ,则会发生 SecurityException。
Now, I'm a little bit confused because in registerListener, we have to define the sampling period in µs and not in Hz .现在,我有点困惑,因为在 registerListener 中,我们必须以µs 而不是 Hz为单位定义采样周期。
If I'm using values for SAMPLINGPERIOD < 5000, the abovementioned exception occurs: java.lang.SecurityException: To use the sampling rate of 4999 microseconds, app needs to declare the normal permission HIGH_SAMPLING_RATE_SENSORS.如果我使用 SAMPLINGPERIOD < 5000 的值,则会发生上述异常: java.lang.SecurityException:要使用 4999 微秒的采样率,应用程序需要声明正常权限 HIGH_SAMPLING_RATE_SENSORS。
Does this mean that a sampling rate of 200 Hz is equivalent to a sampling period of 5'000 microseconds used in registerListener?这是否意味着 200 Hz 的采样率相当于 registerListener 中使用的 5'000 微秒的采样周期? Or is this sensor-dependent?还是这取决于传感器?
Thanks!谢谢!
也许,我刚刚找到了答案:5'000 µs 是 0.005 秒,即我们每秒有 200 个事件 (1/0.005),即 200 Hz。
Yes, SENSOR_DELAY_FASTEST requires the new HIGH_SAMPLING_RATE_SENSORS permission.是的,SENSOR_DELAY_FASTEST 需要新的 HIGH_SAMPLING_RATE_SENSORS 权限。 The other constants don't require it.其他常量不需要它。 If your code uses a flexible integer definition as SAMPLINGPERIOD, you'll need the permission as soon as you go below 5'000 µs.如果您的代码使用灵活的整数定义作为 SAMPLINGPERIOD,则一旦低于 5'000 µs,您就需要获得许可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.