Ejemplo n.º 1
0
    // Use this for initialization

    void Start()
    {
        // Files are not accessible in the .jar, so copy them to persistentDataPath
        CopyFile("tessdata/", "eng.cube.bigrams");
        CopyFile("tessdata/", "eng.cube.fold");
        CopyFile("tessdata/", "eng.cube.lm");
        CopyFile("tessdata/", "eng.cube.nn");
        CopyFile("tessdata/", "eng.cube.params");
        CopyFile("tessdata/", "eng.cube.size");
        CopyFile("tessdata/", "eng.cube.word-freq");
        CopyFile("tessdata/", "eng.tesseract_cube.nn");
        CopyFile("tessdata/", "eng.traineddata");
        CopyFile("tessdata/", "jpn.traineddata");
        CopyFile("tessdata/", "eng.user-patterns");
        CopyFile("tessdata/", "eng.user-words");
        CopyFile("tessdata/", "osd.traineddata");
        CopyFile("tessdata/", "pdf.ttf");
        CopyFile("tessdata/tessconfigs/", "debugConfigs.txt");
        CopyFile("tessdata/tessconfigs/", "recognitionConfigs.txt");

        TesseractWrapper_And tesseract = new TesseractWrapper_And();
        string datapath = System.IO.Path.Combine(Application.persistentDataPath, "tessdata");

        tesseract.Init("eng", datapath);
        tesseract.Init("jpn", datapath);

        string result = tesseract.RecognizeFromTexture(texture, false);

        text.text = result ?? "Error: " + tesseract.errorMsg;
    }
Ejemplo n.º 2
0
    public void Translate()
    {
        text.text = "Please wait...";
        //CopyFile("tessdata/", "eng.cube.bigrams");
        //CopyFile("tessdata/", "eng.cube.fold");
        //CopyFile("tessdata/", "eng.cube.lm");
        // CopyFile("tessdata/", "eng.cube.nn");
        // CopyFile("tessdata/", "eng.cube.params");
        // CopyFile("tessdata/", "eng.cube.size");
        // CopyFile("tessdata/", "eng.cube.word-freq");
        // CopyFile("tessdata/", "eng.tesseract_cube.nn");
        // CopyFile("tessdata/", "eng.traineddata");
        CopyFile("tessdata/", "jpn.traineddata");
        CopyFile("tessdata/", "jpn_vert.trainneddata");
        // CopyFile("tessdata/", "eng.user-patterns");
        // CopyFile("tessdata/", "eng.user-words");
        CopyFile("tessdata/", "osd.traineddata");
        CopyFile("tessdata/", "pdf.ttf");
        CopyFile("tessdata/tessconfigs/", "debugConfigs.txt");
        CopyFile("tessdata/tessconfigs/", "recognitionConfigs.txt");
        string datapath = System.IO.Path.Combine(Application.persistentDataPath, "tessdata");
        TesseractWrapper_And tesseract = new TesseractWrapper_And();

        // tesseract.Init("eng", datapath);
        tesseract.Init("jpn", datapath);
        string result = tesseract.RecognizeFromTexture(texture, false);

        getresult = result;
        getresult = string.Concat(result.Where(c => !char.IsWhiteSpace(c)));
        OutputData();
        Record();
    }