Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tesseract 4 win64 giving exception on Arabic language #6

Open
ghost opened this issue Jan 9, 2018 · 3 comments
Open

Tesseract 4 win64 giving exception on Arabic language #6

ghost opened this issue Jan 9, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 9, 2018

When try to extract content of Arabic image the code throwing System.AccessViolationException , and its happening only when Arabic language is selected.

Giving stack trace below
System.AccessViolationException was unhandled HResult=-2147467261 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=InteropRuntimeImplementer.TessApiSignaturesInstance StackTrace: at InteropRuntimeImplementer.TessApiSignaturesInstance.TessApiSignaturesImplementation.BaseApiInit(HandleRef handle, String datapath, String language, Int32 mode, String[] configs, Int32 configs_size, String[] vars_vec, String[] vars_values, UIntPtr vars_vec_size, Boolean set_only_non_debug_params) at Tesseract.Interop.TessApi.BaseApiInit(HandleRef handle, String datapath, String language, Int32 mode, IEnumerable1 configFiles, IDictionary2 initialValues, Boolean setOnlyNonDebugParams) at Tesseract.TesseractEngine.Initialise(String datapath, String language, EngineMode engineMode, IEnumerable1 configFiles, IDictionary2 initialValues, Boolean setOnlyNonDebugVariables) at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode) at TexlangRECOEngineAPI.RECOCALL.ReadOCR(HttpPostedFileBase file, String Language, String ext, Boolean Preprocess, Boolean PDF) in C:\Users\Megdap\Documents\Visual Studio 2015\Projects\TexlangRECOEngineAPI\TexlangRECOEngineAPI\RECOCALL.cs:line 135 at TexlangRECOEngineAPI.RECOSERVICE.GetExtratedText(String key, String file, Formats f, Language language) in C:\Users\Megdap\Documents\Visual Studio 2015\Projects\TexlangRECOEngineAPI\TexlangRECOEngineAPI\RECOSERVICE.svc.cs:line 99 at SyncInvokeGetExtratedText(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result) at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item)
at System.Runtime.InputQueue1.EnqueueAndDispatch(Item item, Boolean canDispatchOnThisThread) at System.Runtime.InputQueue1.EnqueueAndDispatch(T item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
at System.ServiceModel.Channels.SingletonChannelAcceptor3.Enqueue(QueueItemType item, Action dequeuedCallback, Boolean canDispatchOnThisThread) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.CompleteParseAndEnqueue(IAsyncResult result) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.HandleParseIncomingMessage(IAsyncResult result) at System.Runtime.AsyncResult.SyncContinue(IAsyncResult result) at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(ReplyChannelAcceptor replyChannelAcceptor, Action dequeuedCallback, AsyncCallback callback, Object state) at System.ServiceModel.Channels.HttpChannelListener1.HttpContextReceivedAsyncResult1.ProcessHttpContextAsync() at System.ServiceModel.Channels.HttpChannelListener1.BeginHttpContextReceived(HttpRequestContext context, Action acceptorCallback, AsyncCallback callback, Object state)
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
at System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback callback, Object state)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequestWithFlow(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
InnerException:
`

The C# code :-

` using (IResultRenderer renderer = Tesseract.ResultRenderer.CreateTextRenderer(outputpath))
{
using (renderer.BeginDocument("Test"))
{

                        string configurationFilePath = tessdatapath;
                        using (TesseractEngine engine = new TesseractEngine(configurationFilePath, "ara", EngineMode.TesseractAndLstm))
                        {
                            string tifFile = filepathnew;
                            using (Pix img = Pix.LoadFromFile(tifFile))
                            {
                                using (Page page = engine.Process(img, "Test"))
                                {
                                    
                                    outs = page.GetHOCRText(1, true).ToString();
                                    renderer.AddPage(page);
                                }
                            }
                        }
                    }
                }` 

Please help me on this, the code is working well for other languages.

@ahmed-tea
Copy link

@BladeRunner1989
May be the problem because this build work for OcrEngineMode=0 (OEM_TESSERACT_ONLY)

@tdhintz
Copy link
Owner

tdhintz commented Apr 2, 2018 via email

@ghost
Copy link
Author

ghost commented Apr 3, 2018

The above build is working smoothly for all other languages, with LSTM and all PSM mode. Its only breaking when i use Arabic language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants