Nandha
Nandha

Reputation: 377

Tesseract for Unity

Here i like to know about how to implement Tesseract for Unity.

I found a link

But not a sample , they have given a dll, After importing the Dll i have followed the below code but getting some errors,

public string GetText(Bitmap imgsource)
{
    var ocrtext = string.Empty;
    using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))
    {
        using (var img = PixConverter.ToPix(imgsource))
        {
            using (var page = engine.Process(img))
            {
                ocrtext = page.GetText();
            }
        }
    }

    return ocrtext;
}

But getting error like,

Assets\Scripts\TesseractOCR.cs(20,27): error CS0246: The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)


But there is no error in Visual Studio, it shows only in Editior.

I have placed the tesseract plugin and System.drawing plugin inside Assets\Plugins

Any other alternative ways?

Thanks&Regards,

Nandha

Upvotes: 0

Views: 1767

Answers (2)

andreasnico
andreasnico

Reputation: 1488

You have to reference System.Drawing.dll in your solution

Upvotes: 0

DomCR
DomCR

Reputation: 573

I've been trying to use the dll in unity using the github repository, but it seems incompatible, it gives an error that says is compiled in x86 and asks you to compile it in x64. I've seen that you have the option to add tesseract via nuget:

enter image description here

If the tesseract is the same you can use the nuget package instead of the one that you are trying to use from github.

Upvotes: 1

Related Questions