예제 #1
0
    private void Recognize(Texture2D texture)
    {
        var result = _tesseractDriver?.Recognize(texture);

        AddToTextDisplay(result);
        SetImageDisplay();
    }
예제 #2
0
 private void Recoginze(Texture2D outputTexture)
 {
     ClearTextDisplay();
     AddToTextDisplay(_tesseractDriver.CheckTessVersion());
     _tesseractDriver.Setup();
     AddToTextDisplay(_tesseractDriver.Recognize(outputTexture));
     AddToTextDisplay(_tesseractDriver.GetErrorMessage(), true);
 }
    private void Recoginze(Texture2D outputTexture)
    {
        // Clear out the text
        ClearTextDisplay();

        // Add the Tesseract Version to the text to the Display
        AddToTextDisplay(_tesseractDriver.CheckTessVersion());

        // Start up the Tesseract Driver
        _tesseractDriver.Setup();

        // Add the Recognized Text to the Display
        AddToTextDisplay(_tesseractDriver.Recognize(outputTexture));

        // Add any error messages To the Display
        AddToTextDisplay(_tesseractDriver.GetErrorMessage(), true);
    }
    public void ApplyContrast(Texture2D outputTexture)
    {
        float contrastD = (float)contrast;

        Texture2D contrastImg = new Texture2D(outputTexture.width, outputTexture.height);

        contrastImg.SetPixels(outputTexture.GetPixels());
        //  contrastImg.LoadImage(outputTexture.bytes);
        contrastImg.Apply();
        var rawImage = outputTexture.GetPixels32();

        ProcessImage(ref rawImage, outputTexture.width, outputTexture.height);
        contrastImg.SetPixels32(rawImage);
        contrastImg.Apply();

        /*
         * if (contrastD < -100f) contrastD = -100f;
         * if (contrastD > 100f) contrastD = 100f;
         * contrastD = (100.0f + contrastD) / 100.0f;
         * contrastD *= contrastD;
         * Debug.Log("ContrastD " + contrastD);
         * //  contrastD = 1;
         * //  Debug.Log("ContrastD " + contrastD);
         * Color color;
         * for (int x = 0; x < contrastImg.width; x++)
         * {
         *  for (int y = 0; y < contrastImg.height; y++)
         *  {
         *      color = webcam.GetPixel(x, y);
         *    //  Debug.Log("Original Colour:" + color);
         *      float pR = color.r;
         *      pR -= 0.5f;
         *      pR *= contrastD;
         *      pR += 0.5f;
         *      if (pR < 0f) pR = 0f;
         *      if (pR > 1f) pR = 1f;
         *
         *      float pG = color.g;
         *      pG -= 0.5f;
         *      pG *= contrastD;
         *      pG += 0.5f;
         *      if (pG < 0f) pG = 0f;
         *      if (pG > 1f) pG = 1;
         *
         *      float pB = color.b;
         *      pB -= 0.5f;
         *      pB *= contrastD;
         *      pB += 0.5f;
         *      if (pB < 0f) pB = 0f;
         *      if (pB > 1f) pB = 1f;
         *    //      Debug.Log("New Colour:" + System.Convert.ToByte(pR) + " " + pG + " " + pB);
         *      Color c = FromArgb(pR, pG, pB);
         *   //  Debug.Log("New Colour2:" + c);
         *     contrastImg.SetPixel(x, y, c);
         *      contrastImg.Apply();
         *  }
         * } */
        contrastImg.Apply();


        outputImage.material.mainTexture = contrastImg;
        byte[] bytes = contrastImg.EncodeToPNG();
        File.WriteAllBytes(Application.dataPath + "/Snapshots/Screenshot_" + System.DateTime.Now.ToString("dd-MM-yyyy_hh-mm-ss") + ".png", bytes);
        Debug.Log("Contrast done");
        GetWords(_tesseractDriver.Recognize(contrastImg));
    }
예제 #5
0
 private void OnSetupCompleteRecognize()
 {
     AddToTextDisplay(_tesseractDriver.Recognize(_texture));
     AddToTextDisplay(_tesseractDriver.GetErrorMessage(), true);
     SetImageDisplay();
 }