1

I want to calculate user steps(like pedometer).I know that with iPhone 5s, 6 and 6+ we can use CMStepCounter or CMPedometer class(which use M7 chip of devices) but iPhone 5 and lower versions does not support M7 chip, so we can't use CoreMotion. By searching all over internet i came to know that we can use accelerometer sensor for this purpose. But after spending a lot of time still i'm not able to make an accurate algorithm that works.

Edit2: After spending several days on searching google i tried a lot but still unable to find an working algorithm for counting user step using accelerometer. Can anybody out there who can help me?

Community
  • 1
  • 1
Bharat
  • 2,987
  • 2
  • 32
  • 48
  • probably you need to create an algorithm which monitors the accelerometer's values and recognises the patterns of the steps or walking. – holex Mar 19 '15 at 11:56
  • Thanks for quick reply but i dont have any idea about accelerometer, how to get value and how to recognise patterns of the steps or walking. Do you have any sample or resource link? – Bharat Mar 19 '15 at 12:05
  • it is pretty much about a lovely experimental data collection and analysis of people in different age, different gender, different height / weight, etc... – holex Mar 19 '15 at 12:12
  • @holex hey dear can you please suggest or give me reference to find a correct algorithm to count user step using accelerometer? – Bharat Apr 24 '15 at 06:50
  • that is purely an __R&D__ job, my friend. what we did was simple, created an simple app which record the accelerometer's values in background, we put the app on a device into different people's pocket, asked them to walk slowly, normally, fast, then run, then we downloaded the recoded values from the device and we analyzed their patterns we had and according to those details we could build up the algorithm which detects steps and can count them. – holex Apr 24 '15 at 07:33
  • I'm doing the same thing making people to walk at get their data but doing this i'm able to get step count according to one or two people walking pattern. How can i build a general algorithm that works for all people?Can you please show some code? – Bharat Apr 24 '15 at 07:47
  • as I told you, you need to collect many different patterns as you would be able... tens or hundreds form different age groups, heights, weight, and genders, different speeds, shoes, surfaces etc... because until you analyze you data you don't have info about the different patterns. therefore, many different patterns you have, the better step-counter algorithm you can develop at the end of the day. I cannot share an experimental algorithm with you which the company research for spending a lot of money on it..... you need to do your own research, I'm afraid. – holex Apr 24 '15 at 08:30
  • @holex hey buddy...i m also stuck with this having the same kind of problem.I posted a [question](http://stackoverflow.com/questions/29821806/is-there-any-working-algorithm-to-count-steps-on-all-ios-devices-with-or-withou#) but didn't got any positive response. So I just wanted to ask you that I m having the data of people of different age-groups and size but how to generate a unique algorithm by this data that can count step for the people of all age-groups? – Narender Tak Apr 24 '15 at 08:55
  • @NarenderTak, as far as we experienced, everybody steps different as we had different body language; and a wider range of patterns could help us to identify a much wider range of types of steps; or – if you like it – the step counter can be more accurate. just three simple basic scenarios: at the _same_ person the accelerometer show different data if __(A)__ the person walks on plain surface, __(B)__ walks up staircases, __(C)__ walks down staircase... and those steps are valid steps you have to be able to identify. – holex Apr 24 '15 at 10:50
  • @holex, bro i m having all sorts of data as you are saying, i just need an idea to generate a general algorithm that could count steps for all the people.So if you could help in that then it would be very appreciable. – Narender Tak Apr 24 '15 at 11:13
  • @NarenderTak, you need to create your own algorithm to recognize the patterns which _you_ consider as _a_ step. __R&D__. some company spends thousand of pounds to collect data and research an accurate algorithm. they won't share that with anyone by their business interests. the best you can have is the idea of where you can start the actual research. – holex Apr 24 '15 at 11:45

1 Answers1

0

CMMotionManager is what you are looking for if you are using later versions of iOS. However, if you want to continue with iOS 5 or lower you need to use the following although this is deprecated.

UIAccelerometer * accelerometer = [UIAccelerometer sharedAccelerometer];
accelerometer.delegate = self;

The method where you can get x, y, z values is:

-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
    //Check your x,y,z values to find step ... 
}

If you need to know the logic behind step counter you can search and read through in Google :)

eracube
  • 2,484
  • 2
  • 15
  • 18
  • I need iOS 6+ or even 7+ would also be ok.. Also i have been searching for entire day for logic behind step count but didn't get it. – Bharat Mar 19 '15 at 12:28
  • Then you have to look at [CMMotionManager] (https://developer.apple.com/library/ios/documentation/CoreMotion/Reference/CMMotionManager_Class/) – eracube Mar 19 '15 at 12:32
  • I tried with CMStepCounter but seems it make use of M7 processor so i dont able to get step count in iPhone5. – Bharat Mar 20 '15 at 13:25