Search code examples
androidgoogle-glassdetectionaero-glass

Wink detection on Google Glass with XE22


I'm trying to use this library:

https://github.com/thorikawa/EyeGestureLib

but it not works..

When app starts, occurs a NullPointerException on this line of "onStart()" function:

mEyeGestureManager.register(target1, mEyeGestureListener);
mEyeGestureManager.register(target2, mEyeGestureListener);

I've the other code like the appDemo exposed in the github repository and this lines in "onCreate" function:

mEyeGestureManager = EyeGestureManager.from(this);
mEyeGestureListener = new EyeGestureListener();

Any suggestion? Is there an update library?


Solution

  • The library you posted is pretty outdated (last change 11 months ago). There is currently no official way to detect a wink. I had the same problem to detect only the wink and stop glass to take pictures when detecting it. There are several ways to detect such EyeGestures. Here is what worked for me (quoted from this awesome source):

    To listen to Intent, you have to extend BroadcastReceiver.

    public class EyeGesture extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getStringExtra("gesture").equals("WINK")) {
                //Disable Camera Snapshot
                abortBroadcast();
                Log.e("WINKED ","");
            } else {
                Log.e("SOMETHING", "is detected " + intent.getStringExtra("gesture"));
            }
        }
    }
    

    You must register the intent in the Manifest as below:

    <receiver android:name="com.inno.inno.glassplugin.EyeGesture">
        <intent-filter>
            <action android:name="com.google.android.glass.action.EYE_GESTURE" />
        </intent-filter>
    </receiver>
    

    The name specified in the Manifest must match the name of the class listening to the intent which is EyeGesture.

    Simple as that. No library required but only WINK can be detected. It also stops Glass from taking picture when wink is detected. You can comment abortBroadcast(); if you want Glass to take picture when event is detected.