problem with constructor/recognition

Jul 7, 2010 at 1:32 PM
Edited Jul 7, 2010 at 1:33 PM
Hi, I was trying to do some OCR on my files with Puma and this is what i received using sample code : var pumaPage = new PumaPage("p13ano.bmp"); using (pumaPage) { pumaPage.FileFormat = PumaFileFormat.RtfAnsi; pumaPage.EnableSpeller = false; pumaPage.Language = PumaLanguage.English; pumaPage.RecognizeToFile("page001.rtf"); } It gives ArgumentException "Parameter is not valid" from constructor , details: System.ArgumentException was unhandled Message=Parameter is not valid. Source=System.Drawing StackTrace: at System.Drawing.Bitmap..ctor(String filename) at Puma.Net.PumaPage.LoadImage(String fileName) at Puma.Net.PumaPage..ctor(String imageFileName) at ConsoleApplication3.Program.Main(String[] args) in C:\Users\piotrs\tesseract\testPuma1\ConsoleApplication3\ConsoleApplication3\Program.cs:line 14 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: when i change first line to : var pumaPage = new PumaPage(new Bitmap("p13ano.bmp")); it does compile and run but no output and no exception is produced. Also if i change recognizeToFile to Console.WriteLine(pumaPage.RecognizeToString()); Console.Read(); it gives correct result. Am i doing sth wrong?
Coordinator
Jul 7, 2010 at 1:48 PM
According to the stack trace you've provided the exception was inside Bitmap constructor. This can be the reason of the known PumaPage class bug - when it's created the current directory environment variable is changed and the file is searched within a different directory. I may assume that the same happens for the output file - it's actually created not in the folder where the sample program executable file is situated. Try to define full path for the output file.
Jul 7, 2010 at 2:16 PM
that was it , thx a lot