Program to Extract Text from Image using Tesseract in VB.net

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 1166
Imports Tesseract

Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim testImagePath = "C\test.png"
Dim dataPath = "C\teserractdata"

Try
Using tEngine = New TesseractEngine(dataPath, "eng", EngineMode.[Default])
'creating the tesseract OCR engine with English as the language
Using img = Pix.LoadFromFile(testImagePath)
' Load of the image file from the Pix object which is a wrapper for Leptonica PIX structure
Using page = tEngine.Process(img)
'process the specified image
Dim text = page.GetText()
'Gets the image's content as plain text.
Console.WriteLine(text)
'display the text
Console.WriteLine(page.GetMeanConfidence())
'Get's the mean confidence that as a percentage of the recognized text.
Console.ReadKey()
End Using
End Using
End Using
Catch e As Exception
Console.WriteLine("Unexpected Error: " + e.Message)
End Try
End Sub
End Class
End Namespace

Comments or Responses

Login to post response