google-glass – Google Glass Eye Gesture Crashing(EyeGestureLib)

我正在尝试使用
EyeGestureLib检查Wink from Glass.

我创建了一个新项目,并完成了该项目对样本项目here所做的工作.

我的代码的问题部分如下:

private EyeGestureManager mEyeGestureManager;
private EyeGestureListener mEyeGestureListener;

private EyeGesture target1 = EyeGesture.WINK;
private EyeGesture target2 = EyeGesture.DOUBLE_BLINK;

在onCreate里面,我有:

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

    // print out each eye gesture is supported or not
    for (EyeGesture eg : EyeGesture.values()) {
        boolean supported = mEyeGestureManager.isSupported(eg);
        Log.d(TAG, eg.name() + ":" + supported);
    }

我的程序在打开后立即崩溃.我意识到问题是它试图访问时
mEyeGestureManager.代码中使用mEyeGestureManager的任何地方都会使程序崩溃.根据我观察到的情况,即使在mEyeGestureManager = EyeGestureManager.from(this)之后,mEyeGestureManager也为null;

当我改变

mEyeGestureManager = EyeGestureManager.from(this);

mEyeGestureManager = new EyeGestureManager();

它会停止崩溃并且mEyeGestureManager不再为null但不会检测眨眼或双眨眼.

我的玻璃杯正在运行XE21,但我把它降级到XE18.3因为我的研究表明EyeGestureLib在Glass版本上不能正常工作> XE18.3.

EyeGestures NOT working in 19.1

https://github.com/thorikawa/EyeGestureLib/issues/2

现在我有XE18.3,但它无法正常工作.我有时,Wink无法正常工作
mEyeGestureManager = new EyeGestureManager();
我得到:

Supported:﹕ BLINK:false
Supported:﹕ DOFF:false
Supported:﹕ DON:false
Supported:﹕ DOUBLE_BLINK:false
Supported:﹕ DOUBLE_WINK:false
Supported:﹕ LOOK_AT_SCREEN:false
Supported:﹕ LOOK_AWAY_FROM_SCREEN:false
Supported:﹕ WINK:false

但是当我有:

mEyeGestureManager = EyeGestureManager.from(this);

它马上就崩溃了.

我去安装already compiled example “EyeGestureDemo-debug-1.1.apk”并且工作得非常好,但是我没有.

我究竟做错了什么?我一直试图这样做3天了. Google没有这方面的官方API,但我不想等到他们发布一个.我尽快为我的学校项目需要这个.
任何人都有任何想法可能是什么问题?

编辑:
CRASH LOG

12-02 09:39:54.347    3758-3758/com.inno.inno.glassplugin D/AndroidRuntime﹕ Shutting down VM
12-02 09:39:54.347    3758-3758/com.inno.inno.glassplugin W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41f78bd8)
12-02 09:39:54.363    3758-3758/com.inno.inno.glassplugin E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.inno.inno.glassplugin, PID: 3758
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inno.inno.glassplugin/com.inno.inno.glassplugin.MainActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2235)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2285)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1236)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:149)
            at android.app.ActivityThread.main(ActivityThread.java:5061)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.inno.inno.glassplugin.MainActivity.onCreate(MainActivity.java:92)
            at android.app.Activity.performCreate(Activity.java:5236)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1089)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2285)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1236)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:149)
            at android.app.ActivityThread.main(ActivityThread.java:5061)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)

最佳答案 API已经很久以前发生了变化(我认为XE 20左右).

我不得不用反射进行相当多的挖掘,以找出EyeGestureManager的工作原理.

这是我的更新版本,以及一些演示用法的示例代码:https://gist.github.com/victorkp/9094a6aea9db236a97f3

    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞