/// <summary> /// gesture recognizer registration for the device /// </summary> /// <param name="adapter">The adapter.</param> /// <returns>A gesture recognizer for recognizing gestures</returns> private GestureRecognizer registerGestureRecognizer(AbstractBrailleIOAdapterBase adapter) { if (adapter != null) { var blobTracker = new BlobTracker(); var gestureRecognizer = new GestureRecognizer(blobTracker); var tabClassifier = new TapClassifier(); var multitouchClassifier = new MultitouchClassifier(); // add several classifiers to interpret the tracked blobs gestureRecognizer.AddClassifier(tabClassifier); gestureRecognizer.AddClassifier(multitouchClassifier); // start tracking fo blobs blobTracker.InitiateTracking(); return(gestureRecognizer); } return(null); }
private void initalizeGestureRecognition(BrailleIODevice device) { // gesture recognizer registration for the device var blobTracker = new BlobTracker(); var gestureRecognizer = new GestureRecognizer(blobTracker); //int c = 0; // try to register blob tracker blobTrackers.AddOrUpdate(device, blobTracker, (key, existingBlobTracker) => { // If this delegate is invoked, then the key already exists. return blobTracker; } ); //while (!blobTrackers.TryAdd(device, blobTracker) && c++ < 20) { Thread.Sleep(5); }; //if (c > 19) throw new AccessViolationException("Cannot add blob tracker to dictionary - access denied"); // try to register gesture recognizer gestureRecognizers.AddOrUpdate(device, gestureRecognizer, (key, existingGestureRecognizer) => { // If this delegate is invoked, then the key already exists. if (existingGestureRecognizer != null) { existingGestureRecognizer.FinishEvaluation(); } return gestureRecognizer; } ); //while (!gestureRecognizers.TryAdd(device, gestureRecognizer) && c++ < 40) { Thread.Sleep(5); }; //if (c > 39) throw new AccessViolationException("Cannot add gesture recognizer to dictionary - access denied"); var multitouchClassifier = new MultitouchClassifier(); var tabClassifier = new TapClassifier(); gestureRecognizer.AddClassifier(tabClassifier); gestureRecognizer.AddClassifier(multitouchClassifier); blobTracker.InitiateTracking(); }