使用iPhone / iPad中的加速度计进行水平和垂直振动计数 [英] horizontal and verticle shake count using accelerometer in iPhone/iPad

查看:314
本文介绍了使用iPhone / iPad中的加速度计进行水平和垂直振动计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算水平和垂直摇晃次数,我已经参考 UIAcceleration

i want to count number of shake horizontally and vertically,i have referred to UIAcceleration

我还提到运动事件

但无法启动用更好的方法。
任何类型的帮助是高度赞赏,代码,参考或任何类型。

But couldn't come up with better approach. Any kind of help is highly appreciated , code , reference, or any type.

我只是想通过摇动iphone计数摇动用户数设备,摇动可以垂直或水平持有iphone以正常方式(主页键在底部)

i just want to count the number of shake user make by shaking the iphone device, the shake can be vertically or horizontally holding iphone in normal way(home key at the bottom)

推荐答案

尝试< =https://github.com/millenomi/diceshaker/tree/master/iPhone =nofollow> DiceShaker 。您需要使用清单4-6的运动事件(也称为高通滤波器计算)文档来检测用户提供的加速度。

Try DiceShaker. You'll need to use the code for "Isolating Instantaneous Motion from Acceleration Data" given in Listing 4-6 of the motion events (also called high-pass filter computation) documentation to detect acceleration provided by user.

编辑:加速度计不断提供重力分量读数,因为加速度计与一束弹簧一起决定力分量每个弹簧的长度)增加/减少。因此,只需删除恒定的重力(始终工作的力)组件,以检测由用户提供的更改(因此名称为高通)。幸运的是,我们不需要弄清楚如何,因为苹果已经做了艰苦的工作,并在他们的文档中给出方程!

EDIT: The accelerometer constantly provides the gravity component readings because the accelerometer works with a bunch of springs that determine the force component (in the direction of each spring's length) by the increase/decrease in the spring's length. So just remove the constant gravity(the force that's ALWAYS working) component to detect the change provided by the user (hence the name high-pass). Luckily, we don't need to figure out how to because Apple has done the hard work and given the equations in their documentation!

这篇关于使用iPhone / iPad中的加速度计进行水平和垂直振动计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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