How to count steps using an Accelerometer?

前端 未结 2 755
死守一世寂寞
死守一世寂寞 2020-12-24 00:01

I have to develop the same functionality as of this Pedometer App

I have observed this Pedometer app in very high detail.

It\'s not a perfect pedometer app.

相关标签:
2条回答
  • 2020-12-24 00:09

    Been counting snores, not steps, but have some of the same issues. No actual answers, but some suggestions:

    1. Require a time interval between steps. Yes, someone can be walking slowly or jogging, but even at the fastest there is a time interval of maybe 1/5 second between steps. If "impacts" appear more rapid than that they're likely just from rebound/rattling.
    2. Rather than your fixed threshold (violence) employ a variable threshold, based on a moving average of previous events.
    3. Consider keeping separate x, y, and z thresholds, based on the assumption that the phone will not, over a short period of time, change orientation.
    4. Rather than just ignoring events stronger than a certain level, consider ignoring those outside a range, with limits specified by two thresholds (one perhaps a fraction of the other).
    5. Consider what happens when you walk -- there is a forward/backward acceleration of the body that is quite rhythmic, along with a "shock" as the foot strikes the ground. It may be best to attempt to ignore the shock (a fairly short-term signal) and instead look for the rhythmic forward/backward motion.

    Another suggestion

    Testing this beast "live" would be impossible. (I can imagine you trying to jog along while holding the laptop in front of you, trying to get the debugger console to focus.) What you should do is first rig your app to make some recordings (ie, write files) containing the raw measurements, then re-rig your app (#ifdefs would be handy here) to be able to "play back" those measurements so that you can step through the app with the debugger and observe its behavior.

    0 讨论(0)
  • 2020-12-24 00:20
            var motionManager = CMMotionManager()
            motionManager.deviceMotionUpdateInterval = 0.1
            motionManager.startDeviceMotionUpdatesToQueue(NSOperationQueue.currentQueue(), withHandler:{
                deviceManager, error in
    
                var accelerationThreshold:Double = 1;
                var userAcceleration:CMAcceleration = deviceManager.userAcceleration;
                if(fabs(userAcceleration.x) > accelerationThreshold) || (fabs(userAcceleration.y) > accelerationThreshold) || (fabs(userAcceleration.z) > accelerationThreshold)
                {
                    println("LowPassFilterSignal")
                }
            })
    
    0 讨论(0)
提交回复
热议问题