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

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 15156
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

Posted by: Nagu0006 on: 7/6/2018 Level:Starter | Status: [Member] | Points: 10
hi,
i am getting error while trying, please help
Error: Default' is not a member of 'System.Windows.Forms.ImeMode

Below Code..
Option Strict Off

Imports Emgu.CV
Imports Emgu.Util
Imports Emgu.CV.OCR
Imports Emgu.CV.Structure




Namespace ConsoleApplication1
Class Program


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

Try
Using tEngine = New Tesseract(dataPath, "eng", ImeMode.[Default])



Using img = Pix.LoadFromFile(testImagePath)
'
Using page = tEngine.Process(img)

Dim text = page.GetText()

'display the text
Console.WriteLine(page.GetMeanConfidence())

Console.ReadKey()
End Using
End Using
End Using
Catch e As Exception
Console.WriteLine("Unexpected Error: " + e.Message)
End Try
End Sub

Private Shared Function Pix() As Object
Throw New NotImplementedException
End Function

End Class

End Namespace

Login to post response