/// <summary> /// Recognize drawn gesture /// </summary> public void Recognize() { if (multiStrokePoints.Count > minimumPointsToRecognize) { multiStroke = new MultiStroke(multiStrokePoints.ToArray()); result = multiStroke.Recognize(ml); isRecognized = true; Debug.Log(result.Score); if (result.Name == "new_elka") { if (result.Score < 1.4f && result.Score > 0.4f) { handBranch.SetActive(false); handBranch2.SetActive(true); SetMessage("MultiStroke is recognized as <color=#ff0000>'" + result.Name + "'</color> with a score of " + result.Score); ControllerPanel4 controllerPanel4 = FindObjectOfType <ControllerPanel4>(); controllerPanel4.RecognizeFirstPicture(); gameObject.SetActive(false); ClearMultiStroke(); } else { ClearMultiStroke(); handBranch.SetActive(true); handBranch2.SetActive(false); SetMessage("Не удалось распознать"); } } else if (result.Name == "new_belka") { if (result.Score < 1.4f && result.Score > 0.5f) { handBranch.SetActive(false); handBranch2.SetActive(true); SetMessage("MultiStroke is recognized as <color=#ff0000>'" + result.Name + "'</color> with a score of " + result.Score); ControllerPanel4 controllerPanel4 = FindObjectOfType <ControllerPanel4>(); controllerPanel4.RecognizeSecondPicture(); gameObject.SetActive(false); ClearMultiStroke(); SetMessage("MultiStroke is recognized as <color=#ff0000>'" + result.Name + "'</color> with a score of " + result.Score); } else { ClearMultiStroke(); handBranch.SetActive(true); handBranch2.SetActive(false); SetMessage("Не удалось распознать"); } } else { SetMessage("Не удалось распознать"); } //SetMessage("MultiStroke is recognized as <color=#ff0000>'" + result.Name + "'</color> with a score of " + result.Score); } }
/// <summary> /// Add multistroke to the library /// </summary> public void AddMultiStroke() { multiStroke = new MultiStroke(multiStrokePoints.ToArray(), newMultiStrokeName); ml.AddMultiStroke(multiStroke); SetMessage(newMultiStrokeName + " has been added to the library"); id = System.Guid.NewGuid().ToString("N"); newMultiStrokeName = text + ":" + id; SetMessage(newMultiStrokeName); }
/// <summary> /// Recognize drawn gesture /// </summary> void Recognize() { if (multiStrokePoints.Count > minimumPointsToRecognize) { multiStroke = new MultiStroke(multiStrokePoints.ToArray()); result = multiStroke.Recognize(ml); isRecognized = true; SetMessage("MultiStroke is recognized as <color=#ff0000>'" + result.Name + "'</color> with a score of " + result.Score); } }
/// <summary> /// Recognize drawn gesture /// </summary> public void Recognize() { if (multiStrokePoints.Count > minimumPointsToRecognize) { multiStroke = new MultiStroke(multiStrokePoints.ToArray()); result = multiStroke.Recognize(ml); isRecognized = true; string[] names = result.Name.Split(':'); SetMessage("MultiStroke is recognized as <color=#ff0000>'" + names[0] + "'</color> with a score of " + result.Score); } }
public void Rewrite() { if (multiStrokePoints.Count > minimumPointsToRecognize) { multiStroke = new MultiStroke(multiStrokePoints.ToArray()); result = multiStroke.Recognize(ml); if (OnRecognition != null) { OnRecognition(result); } } ClearGesture(); }
/// <summary> /// Add multistroke to the library /// </summary> public void AddMultiStroke() { multiStroke = new MultiStroke(multiStrokePoints.ToArray(), newMultiStrokeName.text); ml.AddMultiStroke(multiStroke); SetMessage(newMultiStrokeName.text + " has been added to the library"); }
// Track user input and fire OnRecognition event when necessary. void Update() { // Track user input if GestureRecognition is enabled. if (isEnabled) { // If it is a touch device, get the touch position // if it is not, get the mouse position if (Utility.IsTouchDevice()) { if (Input.touchCount > 0) { virtualKeyPosition = new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y); } } else { if (Input.GetMouseButton(0)) { virtualKeyPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y); } } // It is not necessary to track the touch from this point on, // because it is already registered, and GetMouseButton event // also fires on touch devices if (Input.GetMouseButtonDown(0)) { point = Vector2.zero; lastPoint = Vector2.zero; AddStroke(); } // It is not necessary to track the touch from this point on, // because it is already registered, and GetMouseButton event // also fires on touch devices if (Input.GetMouseButton(0)) { switch (gestureLimitType) { case GestureLimitType.None: RegisterPoint(); break; case GestureLimitType.RectBoundsIgnore: if (RectTransformUtility.RectangleContainsScreenPoint(gestureLimitRectBounds, virtualKeyPosition, null)) { RegisterPoint(); } break; case GestureLimitType.RectBoundsClamp: virtualKeyPosition = Utility.ClampPointToRect(virtualKeyPosition, gestureLimitRect); RegisterPoint(); break; } } // Capture the multi stroke, recognize it, fire the recognition event, // and clear the multi stroke from the screen. if (Input.GetMouseButtonDown(1)) { if (multiStrokePoints.Count > minimumPointsToRecognize) { multiStroke = new MultiStroke(multiStrokePoints.ToArray()); result = multiStroke.Recognize(ml); if (OnRecognition != null) { OnRecognition(result); } } ClearGesture(); } } }