OCR exception at step 201 WITHOUT Multithread

Discussions about machine vision support in GdPicture.
Post Reply
OLager
Posts: 10
Joined: Tue Sep 07, 2010 8:17 am

OCR exception at step 201 WITHOUT Multithread

Post by OLager » Tue Sep 07, 2010 9:19 am

Hello,

I tried your .net example "PDF to PDF-OCR". Because I have to process more than one PDF, I put the code into a FOR EACH loop.
In the begining I initialize a new oGdPictureImaging object and in the end of each PDF I set oGdPictureImaging = Nothing. Unfortunately there is no dispose method.
Never the less it seems to be that there are more than one oGdPictureImaging objects and I get the following error:
System.Exception: OCR exception at step 201: Ein Aufrufziel hat einen Ausnahmefehler verursacht.
Source: mscorlib
StackTrace: bei System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bei System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
bei System.Delegate.DynamicInvokeImpl(Object[] args)
bei ?.?.?(Int32 ?, Int32 ?, Int32 ?, Int32 ?, Int32 ?, TesseractDictionary ?, String ?, String ?, IntPtr& ?, Int32& ?, Int32 ?)
bei ?.?.?(Int32 ?, Int32 ?, Int32 ?, Int32 ?, Int32 ?, TesseractDictionary ?, String ?, String ?, IntPtr& ?, Int32& ?, Int32 ?)
bei GdPicture.GdPictureImaging.PdfAddGdPictureImageToPdfOCR(Int32 PdfID, Int32 ImageID, TesseractDictionary Dictionary, String DictionaryPath, String CharWhiteList)
Here is my code:

Code: Select all

For Each file In OpenFileDialog1.FileNames
	oGdPictureImaging = New GdPicture.GdPictureImaging
	Dim InputFileName As String = file
	Dim OutputFileName As String = _OutputDir & "/" & InputFileName.Substring(InputFileName.LastIndexOf("\") + 1, InputFileName.Length - InputFileName.LastIndexOf("\") - 1)
	Dim ImageID As Integer
	Dim Dict As GdPicture.TesseractDictionary
	Dim InputPDFID As Integer
	Dim PdfID As Integer
	Dim Resolution As Integer = Val(TextBox2.Text)
	
	oGdPictureImaging.SetLicenseNumber("")
	Dict = GdPicture.TesseractDictionary.TesseractDictionaryGerman
	
	PdfID = oGdPictureImaging.PdfOCRStart(OutputFileName, CheckBox1.Checked, "", "", "", "", "")
	InputPDFID = oGdPictureImaging.PdfReaderLoadFromFile(file)
	If InputPDFID <> 0 Then
	For i As Integer = 1 To oGdPictureImaging.PdfReaderGetPageCount(InputPDFID)
	    oGdPictureImaging.PdfReaderSelectPage(InputPDFID, i)
	    ImageID = oGdPictureImaging.PdfReaderRenderPageToGdPictureImage(InputPDFID, Resolution, True)
	    If ImageID <> 0 Then
	        If CheckBox2.Checked Then 'BW
	            oGdPictureImaging.ConvertTo1Bpp(ImageID)
	        End If
	        oGdPictureImaging.PdfAddGdPictureImageToPdfOCR(PdfID, ImageID, Dict, Application.StartupPath & "/OCR", "")
	        If oGdPictureImaging.GetStat <> GdPicture.GdPictureStatus.OK Then
	            MsgBox("OCR problem on page " + Str(i) + ". Error: " + oGdPictureImaging.GetStat.ToString)
	        End If
	        oGdPictureImaging.ReleaseGdPictureImage(ImageID)
	    Else
	        MsgBox("Can't render page " + Str(i))
	    End If
	    
	Next i
	Else
	MsgBox("Can't open file: " & InputFileName)
	End If
	
	oGdPictureImaging.PdfOCRStop(PdfID)
	oGdPictureImaging = Nothing
Next
Is there an workaround to destroy the object really? Or is there another problem that I can't see?

Thanks Olaf

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: OCR exception at step 201 WITHOUT Multithread

Post by Loïc » Tue Sep 07, 2010 10:21 am

Hi Olaf,

Please check you are using latest version available.
If the problem persists, you can create a new incident at https://www.gdpicture.com/support/getting-support-from-our-team attaching PDF generating the exception and source code to reproduce the issue.

Kind regards,

Loïc

OLager
Posts: 10
Joined: Tue Sep 07, 2010 8:17 am

Re: OCR exception at step 201 WITHOUT Multithread

Post by OLager » Thu Sep 09, 2010 7:47 am

Hi Loïc,

same new facts:

- the error in the PDF (1200 Sites) occurs when there's a page with a barcode (I can reproduce the error)
- the same file as a multitiff shows no error

In the meantime the error - all the time "OCR exception at step 201" - occurs as well when there's no barcode. :shock:

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: OCR exception at step 201 WITHOUT Multithread

Post by Loïc » Thu Sep 09, 2010 8:52 am

Hi Olag,

OK it's great you are able to reproduce the problem. But now I need to reproduce it here for investigation :wink:

See my previous answer: See us image + code snippet.

Another quick suggestion: try to empty all dict files with .user-words extension.

Kind regards,

Loïc

OLager
Posts: 10
Joined: Tue Sep 07, 2010 8:17 am

Re: OCR exception at step 201 WITHOUT Multithread

Post by OLager » Thu Sep 09, 2010 9:04 am

Hi Loïc,

all .user-words are empty.
Unfortunately I can't provide you the PDF-File. All documents are files from a customer and secret.

Olaf

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: OCR exception at step 201 WITHOUT Multithread

Post by Loïc » Thu Sep 09, 2010 1:49 pm

Olaf, if we are not able to reproduce your problem we can't help ! :? So we absolutely need your document for testing purpose.

Thank you for your comprehension.

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests