使用加速度计检测运动-(方向不变)? [英] Detecting movement using accelerometer - (Orientation is not changing)?

查看:329
本文介绍了使用加速度计检测运动-(方向不变)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以使用加速度计检测方向及其变化。

I understand that we can detect orientation and its changes using accelerometer. Like whether the mobile phone is placed upside down, sideways or whatever.

我们能否检测到手机的移动(假设手机方向不变)?

Can we detect movement of the phone (given the phone orientation is not changing)?

就像将手机放在汽车中一样,汽车开始行驶。在这种情况下,手机的方向不一定会改变,但是我可以使用加速度计来检测吗?

Like the mobile phone is placed in a car and the car starts to move. In this case the mobile's orientation is not necessarily changing but can I detect this using accelerometer?

我最多在API-8中看到此功能。

I am looking this feature in API-8 at the most.

推荐答案

是。例如,请参见 LINEAR_ACCELERATION 。即使方向没有变化,您也会看到加速度的变化。

Yes. Look at LINEAR_ACCELERATION for example. Even if the orientation is not changing you will see changes in the acceleration.

请不要尝试对其进行积分以获得速度或位置,因为它不够精确

Just don't try to integrate it to get velocity or position because it is not accurate enough for that.

看看 TYPE_ACCELEROMETER 的长度变化(即 sqrt(x ^ 2 + y ^ 2 + z ^ 2))。定义一个阈值,如果更改超过阈值,则说明设备已移动。

Look at the change in length of TYPE_ACCELEROMETER (i.e. sqrt(x^2+y^2+z^2)). Define a threshold and if the change exceeds the threshold then the device has been moved.

这篇关于使用加速度计检测运动-(方向不变)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆