예제 #1
0
    public void Setup()
    {
        _tesseract = new MyTesseractWrapper();
        string datapath = Application.streamingAssetsPath
                          + "/tessdata/";

        if (_tesseract.Init("eng", datapath))
        {
            Debug.Log("Init Successful");
        }
    }
예제 #2
0
    public string CheckTessVersion()
    {
        _tesseract = new MyTesseractWrapper();

        try
        {
            string version = "Tesseract version: "
                             + _tesseract.Version();
            Debug.Log(version);
            return(version);
        }
        catch (Exception e)
        {
            string errorMessage = e.GetType() + " - " + e.Message;
            Debug.LogError(errorMessage);
            return(errorMessage);
        }
    }
예제 #3
0
 public string Recognize(Texture2D imageToRecognize)
 {
     if (_tesseract == null)
     {
         Debug.Log("Aqui el error");
         try
         {
             _tesseract = new MyTesseractWrapper();
             string answer = _tesseract.Recognize(imageToRecognize);
             Debug.Log("Ha leido esto: " + answer);
             return(answer);
         }
         catch (Exception e)
         {
             Debug.Log("Excepción: " + e.GetType() + " - " + e.Message);
             return("");
         }
     }
     return(_tesseract.Recognize(imageToRecognize));
 }
예제 #4
0
    public void OcrSetup(UnityAction onSetupComplete)
    {
        _tesseract = new MyTesseractWrapper();

#if UNITY_EDITOR
        string datapath = Path.Combine(Application.streamingAssetsPath, "tessdata");
#elif UNITY_ANDROID
        string datapath = Application.persistentDataPath + "/tessdata/";
#else
        string datapath = Path.Combine(Application.streamingAssetsPath, "tessdata");
#endif

        if (_tesseract.Init("eng", datapath))
        {
            Debug.Log("Init Successful");
            onSetupComplete?.Invoke();
        }
        else
        {
            Debug.LogError(_tesseract.GetErrorMessage());
        }
    }