使用 XE22 在 Google 玻璃上进行眨眼检测

Wink detection on Google Glass with XE22

我正在尝试使用这个库:

https://github.com/thorikawa/EyeGestureLib

但它不起作用..

应用程序启动时,"onStart()" 函数的这一行发生 NullPointerException:

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

我在 github 存储库中公开了其他代码,例如 appDemo,"onCreate" 函数中的这行代码:

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

有什么建议吗?有更新库吗?

您发布的库非常过时(最后一次更改是在 11 个月前)。目前没有官方的方法来检测眨眼。我遇到了同样的问题,只检测到眨眼和停止玻璃在检测时拍照。有多种方法可以检测此类 EyeGestures。这是对我有用的(引自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.