Dumbo
Dumbo

Reputation: 14132

Detect if the phone is in pocket or not

This question is not exactly about code but rather implementation.

I am working on an app that requires to check if the phone is in pocket or not. I have a simple algorithm to detect user steps when walking. The problem is movement in hand can also be registered as a step, e.g. when user runs the app and zeros the step values from the time that he/she does this to the point that the phone is in pocket, the app registeres a few steps.

My idea is to check proximity sensor and see if the phone is in pocket.

What I do with accelerometer sensor is that I continuesly read the accelerometer values in a buffer, when the buffer gets full then I calculate the steps (while calculating, the buffer is still accepting new accelerometer readings).

Since I heard that proximity sensor is interrupt based and not poll-based (like acc sensor is). How can I coordinate these two together?

Is it safe to say if I check proximity before writing acc values into buffer, and check it again when calculation starts, if proximity was not in FAR mode, I can assume the phone was in the pocket?

Any suggestion is welcome!

Upvotes: 11

Views: 1798

Answers (1)

Vishal Bajpai
Vishal Bajpai

Reputation: 9

In researching legacy applications built before on-device pocket detection was invented, I encountered an interesting approach that utilized a combination of light and proximity sensors.

  1. Proximity Sensor: If It gives 0 (its covered) I would consider it is inside the pocket and start the step calculation, and once it changes to 5 (outside, there is no intermediate value in proximity) I would assume he removed the phone from pocket.

  2. Light Sensor: As a secondary measure, a light sensor threshold can be set (e.g., below 5 lux). Values below the threshold could indicate a pocket environment, but limitations exists such as dark conditions.

  3. Orientation Sensor: In some scenarios, if the orientation sensor consistently detects a downward-facing position, just assume the phone is in a pocket.

Combining Techniques for Robustness: While each method has limitations, combining them can enhance pocket detection accuracy. For instance, requiring two out of three sensors to agree on "in-pocket" can improve reliability.

Upvotes: 0

Related Questions