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

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

问题描述

我想计算水平和垂直方向的摇动次数,我已经提到了

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(底部的Home键)

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)

推荐答案

尝试 DiceShaker .您需要使用

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 :由于加速度计与一堆弹簧一起工作,该加速度计不断提供重力分量的读数,这些弹簧通过增加/减小弹簧力来确定力分量(在每个弹簧的长度方向上).春天的长度.因此,只需移除恒定重力(始终在起作用的力)分量以检测用户提供的更改(因此称为高通).幸运的是,我们不需要弄清楚该怎么做,因为Apple已经完成了艰苦的工作,并在其文档中给出了方程式!

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天全站免登陆