horizontal and vertical shake count using accelerometer in iPhone/iPad

北战南征 提交于 2019-12-10 09:27:09

问题


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

I have also referred to Motion Events

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

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)


回答1:


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!



来源:https://stackoverflow.com/questions/7253058/horizontal-and-vertical-shake-count-using-accelerometer-in-iphone-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!