Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does knocktounlock work?

I am trying to figure out how knocktounlock.com is able to detect "knocks" on the iPhone. I am sure they use the accelerometer to achieve this, however all my tries come up with false flags (if user moves, jumps, etc it sometimes fires)

Basically, I want to be able to detect when a user knocks/taps/smacks their phone (and be able to distinguish that from things that may also give a rise to the accelerometer). So I am looking for sharp high peeks. The device will be in the pocket so the movement of the device will not be very much.

I have tried things like high/low pass (not sure if there would be a better option)

This is a duplicate of this: Detect hard taps anywhere on iPhone through accelerometer But it has not received any answers.

Any help/suggestions would be awesome! Thanks.

EDIT: Looking for more thoughts before I accept the answer below. I did hear back from Knocktounlock and they use the fourth derivative (jounce) to get better values to then analyse. Which is interesting.

like image 846
Jonovono Avatar asked Dec 22 '13 05:12

Jonovono


2 Answers

I would consider knock on the iPhone to be exactly same as bumping two phones with each other. Check out this Github Repo,

https://github.com/joejcon1/iOS-Accelerometer-visualiser

Build&Run the App on iPhone and check out the spikes on Green line. You can see the value of the spike clearly,

Knocking the iPhone:

enter image description here

As you can see the time of the actual spike is very short when you knock the phone. However the spike patterns are little different in Hard Knock and Soft knock but can be distinguished programmatically.

Now lets see the Accelerometer pattern when iPhone moves in space freely,

enter image description here

As you can see the Spikes are bell shaped that means the it takes a little time for spike value to return to 0.

By these pattern it will be easier to determine the knocking pattern. Good Luck.

Also, This will drain your battery out as the sensor will always be running and iPhone needs to persist connection with Mac via Bluetooth.

P.S.: Also check this answer, https://stackoverflow.com/a/7580185/753603

like image 145
TeaCupApp Avatar answered Sep 28 '22 08:09

TeaCupApp


I think the way to go here is using pattern recognition with accelerometer data. You could (write and) train a classifier (e.g. K-nearest neighbor) with data you gathered and that has been classified by hand. Neural networks are also an option. However, there will be many different ways to solve that problem. But there is probably no straightforward way for achieving this.

Some papers showing pattern recognition approaches to similar topics (activity, movement), like http://www.math.unipd.it/~cpalazzi/papers/Palazzi-Accelerometer.pdf (some more, but I am not allowed to post them with my reputation count. You can search for "pattern recognition accelerometer data")

There is also a master thesis about gesture recognition on the iPhone: http://klingmann.ch/msc_thesis_marco_klingmann_iphone_gestures.pdf

In general you won't achieve 100% correct classification. Depending on the time/knowledge one has got the result will vary between good-usable and we-could-use-random-classification-instead.

like image 27
Daniel Witurna Avatar answered Sep 28 '22 07:09

Daniel Witurna