I've been trying to figure out how to use a GestureOverlayView with my
application, and wanted to see if SEQUENCE_INVARIANT would make a
difference. That is, I do this:

gestureLib.setSequenceType(GestureStore.SEQUENCE_INVARIANT);

before trying to use gestureLib.recognize(). The short answer is that
it makes a difference, but the bad part is I haven't had one gesture
match to anything in my GestureLibrary when this option is set this
way, no matter how carefully I draw the input gesture. From the source
code of InstanceLearner.java it appears that the distance value
between vectors is calculated using Squared Euclidean instead of
Cosine when you use SEQUENCE_INVARIANT. Digging deeper than that
starts to hurt my brain so I thought I would post here to find out if
anyone has tried this, or know what SEQUENCE_INVARIANT is supposed to
do. I've tried this in the emulator on an Eclair 2.0 AVD and also on a
Motorola Droid. Here's relevant code from my Activity:

public class MainActivity extends Activity implements
OnGesturePerformedListener {
    private static final String TAG = "Gesture Revealer";
    GestureLibrary gestureLib = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        gestureLib = GestureLibraries.fromFile("/sdcard/gestures");
        if (!gestureLib.load()) {
            Toast.makeText(this, "Could not load /sdcard/gestures",
Toast.LENGTH_SHORT).show();
            finish();
        }

        // Here's where we can change the default values
        //gestureLib.setOrientationStyle
(GestureStore.ORIENTATION_INVARIANT);
        gestureLib.setSequenceType(GestureStore.SEQUENCE_INVARIANT);

        GestureOverlayView gestureView = (GestureOverlayView)
findViewById(R.id.gestureOverlay);
        gestureView.addOnGesturePerformedListener(this);
    }

        @Override
        public void onGesturePerformed(GestureOverlayView view, Gesture
gesture) {
            ArrayList<Prediction> predictions = gestureLib.recognize
(gesture);

            if (predictions.size() > 0) {
                Prediction prediction = (Prediction) predictions.get(0);
                if (prediction.score > 1.0) {
                    Toast.makeText(this, prediction.name,
Toast.LENGTH_SHORT).show();
                }
            }
        }
}

- dave

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to