Skip to content

Commit

Permalink
Cleaned scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
limkarlkenji committed Jul 11, 2023
1 parent 47a90fd commit e0180f7
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 1,208 deletions.
29 changes: 1 addition & 28 deletions Assets/3rdParty/Neelarghya_tesseract-unity/Scripts/Tesseract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
public class Tesseract : MonoBehaviour
{
public static Tesseract Instance;
[SerializeField] private Texture2D imageToRecognize;
[SerializeField] private InputField outputText;
[SerializeField] private RawImage outputImage;
private TesseractDriver _tesseractDriver;
private string _text = "";
private Texture2D _texture;
Expand All @@ -18,27 +15,18 @@ private void Awake()

private void Start()
{
// Texture2D texture = new Texture2D(imageToRecognize.width, imageToRecognize.height, TextureFormat.ARGB32, false);
// texture.SetPixels32(imageToRecognize.GetPixels32());
// texture.Apply();

_tesseractDriver = new TesseractDriver();
//Recognize(texture);
}

public void Recognize(Texture2D outputTexture)
{
_texture = outputTexture;
//ClearTextDisplay();
//AddToTextDisplay(_tesseractDriver.CheckTessVersion());
_tesseractDriver.Setup(OnSetupCompleteRecognize);
}

private void OnSetupCompleteRecognize()
{
AddToTextDisplay(_tesseractDriver.Recognize(_texture));
//AddToTextDisplay(_tesseractDriver.GetErrorMessage(), true);
SetImageDisplay();
}

private void ClearTextDisplay()
Expand All @@ -48,22 +36,7 @@ private void ClearTextDisplay()

private void AddToTextDisplay(string text, bool isError = false)
{
outputText.text = text;
UIHandler.Instance.DisplayResult(text, true);
if (string.IsNullOrWhiteSpace(text)) return;
Debug.Log(text + " " + isError);
// _text += (string.IsNullOrWhiteSpace(displayText.text) ? "" : "\n") + text;

// if (isError)
// Debug.LogError(text);
// else
// Debug.Log(text);
}

private void SetImageDisplay()
{
// RectTransform rectTransform = outputImage.GetComponent<RectTransform>();
// rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,
// rectTransform.rect.width * _tesseractDriver.GetHighlightedTexture().height / _tesseractDriver.GetHighlightedTexture().width);
// outputImage.texture = _tesseractDriver.GetHighlightedTexture();
}
}
Loading

0 comments on commit e0180f7

Please sign in to comment.