This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, March 10, 2008 8:59:47 AM(UTC)
Groups: Registered
Posts: 15
I have a project where I need to OCR the MICR line of a check and parse the result to get the individual data elements (account #, routing #, etc.). I am using Leadtools 14.5
The problem I'm running into is that when I call RasterOcr.SaveResultsToMemory, I lose all the special MICR characters. In looking at the MICR demo the results are saved to a Word document with all the special characters in tact. However, if I use the SaveResultsToMemory in the demo I again lose the special characters.
I am pretty sure this has something to do with character set encoding in the SaveResultsToMemory function. The String type in .Net uses Unicode so I know they handle the characters fine natively (just output the "langPlus" string from my code below in the Visual Studio immediate window and the special characters print as expected). Is there any way to preserve the exact OCR'ed characters when pulling OCR results? Going through a Word document is absolutely not a workable solution.
Even when I loop through the GetRecognizedCharacters array none of the characters match the special MICR characters; yet obviously those characters are recognized internally, otherwise they couldn't have been saved out in Word.
Below is the code I am using to do the OCR (minus error handling and cleanup for readability).
------------------
Private Function DoOcr(ByVal image As IRasterImage) As String
Dim result As String = Nothing
Dim langPlus As String = ChrW(&H2446) + ChrW(&H2447) + ChrW(&H2448) + ChrW(&H2449) + ChrW(&H0)
Dim rasterOcr As New RasterOcr()
rasterOcr.StartUp()
rasterOcr.LanguageCharacterPlus = langPlus
rasterOcr.LanguageCharacterFilter = RasterOcrCharacterFilter.All
Try
Dim zoneData As RasterOcrZoneData = New RasterOcrZoneData
rasterOcr.AddPage(image, -1)
zoneData.Rectangle = New Rectangle(0, 0, image.Width, image.Height)
zoneData.FillMethod = RasterOcrFillMethod.Micr
zoneData.RecognizeModule = RasterOcrRecognizeModule.Auto
zoneData.CharacterFilter = RasterOcrCharacterFilter.Default
zoneData.Type = RasterOcrZoneType.Column
rasterOcr.AddZone(0, 0, zoneData)
rasterOcr.EnableSubSystem = True
rasterOcr.EnableCorrection = True
rasterOcr.SpellLanguageID = RasterOcrLanguage.English
rasterOcr.RecognitionDataFileName = Path.ChangeExtension(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetRandomFileName()), "rdf")
rasterOcr.Recognize(0, 1)
result = rasterOcr.SaveResultsToMemory()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
rasterOcr.ShutDown()
rasterOcr = Nothing
Return result
End Function
-----------------
The resulting string never contains any of the characters in the "langPlus" string. I have also ported the Word save results code from the demo into my project to make sure there wasn't something else going on, and sure enough, the resulting file contained the special characters.
#2
Posted
:
Wednesday, March 12, 2008 6:34:52 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I tested using our demo and the MICR image shipped with our
toolkit.
You can get the actual Unicode character value like this:
Dim c() As Leadtools.Ocr.RasterOcrRecognizedCharacters
c = _rasterOcr.GetRecognizedCharacters(0)
After that, the value of Hex(AscW(c(0).GuessCode)) was
returned as "2446", which is the correct Hex value for the first MICR
character in the image.
#3
Posted
:
Monday, March 24, 2008 4:16:58 AM(UTC)
Groups: Registered
Posts: 15
Thanks.
I tried using GetRecognizedCharacters like you describe (as I said in my post) but I wasn't seeing that it was pulling back the correct characters.
I updated to the latest version and everything works great so it is possible that it was bahaving incorrectly in the older version I was using. However, on hindsight, I don't know if maybe I was doing something wrong (wouldn't be the first time) and it was working before or not (and I don't feel like reverting back to check). If anyone else is having the same issue I describe above I can confirm that with the latest version (14.5.0.72) it works fine.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.