Contact us


All times are UTC - 8 hours



Post new topic Reply to topic  [ 15 posts ] 
Author Message
Offline Profile  


Joined: Fri Aug 30, 2013 4:59 am
Posts: 7
Hello. I need some help with IndexList class

I load image from bytes:

Code:
bool res = dynamicDotNetTwain.LoadImageFromBytes(imageBytes, imageType);


and need put recognized text into byte array using this overload:

Code:
public byte[] OCR(IndexList listImageIndex)


What does the IndexList class mean and how to use it here? I was not able to clarify it from your documentation.

Thanks in advance.


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1701
Hi Khan,

Do you want to load images and OCR these selected files?

If so, please find the code snippet below for your reference:

Code:
Dynamsoft.DotNet.TWAIN.IndexList aryList = new Dynamsoft.DotNet.TWAIN.IndexList();
            for (int i = 0; i < this.dynamicDotNetTwain1.HowManyImagesInBuffer; i++)
            {
                aryList.Add(i);
            }
            this.dynamicDotNetTwain1.CurrentSelectedImageIndicesInBuffer = aryList;

            byte[] sbytes = this.dynamicDotNetTwain1.OCR(this.dynamicDotNetTwain1.CurrentSelectedImageIndicesInBuffer);

Learn more info on IndexList Class >>

Please try it and let me know how it works for you.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Fri Aug 30, 2013 4:59 am
Posts: 7
Catherine wrote:
Hi Khan,

Do you want to load images and OCR these selected files?

If so, please find the code snippet below for your reference:

.....

Please try it and let me know how it works for you.


I tried to use your snippet:


Code:

//Loading image from bytes, not from files
bool loadingSucc = _dynamicDotNetTwain.LoadImageFromBytes(imageBytes, imageType);
       
if (!loadingSucc) { return false; }

try
{
   IndexList imagesList = new IndexList();
    for (int i = 0; i < _dynamicDotNetTwain.HowManyImagesInBuffer; i++)
    {
      imagesList.Add(i);
    }
   _dynamicDotNetTwain.CurrentSelectedImageIndicesInBuffer = imagesList;

   byte[] resultBytes = _dynamicDotNetTwain.OCR(_dynamicDotNetTwain.CurrentSelectedImageIndicesInBuffer);
}
catch (Exception ex)
{
    return false;
}
finally
{
    _dynamicDotNetTwain.RemoveAllImages();
}




But unsuccessfully. No exception occures, and resultBytes array gets only two bytes:
10,
0

Here are hardcoded configurations:

Code:
//DllPath  C:\DynamicOCR.dll  and  C:\DynamicOCRx64.dll
_dynamicDotNetTwain.OCRDllPath = @"C:\";
_dynamicDotNetTwain.OCRLanguage = "eng";
_dynamicDotNetTwain.OCRPageSetMode = PageSetMode.PSM_SINGLE_LINE;
_dynamicDotNetTwain.OCRTessDataPath = @"C:\";    //C:\tessdata\
_dynamicDotNetTwain.OCRUnicodeFontName = "Arial";
_dynamicDotNetTwain.OCRUseDetectedFont = false;
_dynamicDotNetTwain.OCRResultFormat = ResultFormat.Text;


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1701
Hi khan,

Please remove this line below and see if it works.

Code:
// _dynamicDotNetTwain.OCRPageSetMode = PageSetMode.PSM_SINGLE_LINE;


Kindly try it and let me know the result.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Fri Aug 30, 2013 4:59 am
Posts: 7
Catherine wrote:
Hi khan,

Please remove this line below and see if it works.

Code:
// _dynamicDotNetTwain.OCRPageSetMode = PageSetMode.PSM_SINGLE_LINE;


Kindly try it and let me know the result.



Yes, it has begun working.
Thank you very much Catherine.


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1701
Khan, glad to know that you got it working. :lol:

Any further questions, please let me know.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Fri Aug 30, 2013 4:59 am
Posts: 7
Catherine wrote:
Khan, glad to know that you got it working. :lol:

Any further questions, please let me know.


Another problem appeared. When recognizing from some languages, for example from russian, an exception is thrown by method:
DynamicDotNetTwain.LoadImageFromBytes

AccessViolationException:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1701
Hi Khan,

I'm not sure why the issue occured in your application. Do you have any additional information about this issue?

BTW, I googled the error message on the internet and found this article:
http://social.msdn.microsoft.com/Forums ... ted-memory

Hope it helps!

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Fri Aug 30, 2013 4:59 am
Posts: 7
Catherine wrote:
Hi Khan,

I'm not sure why the issue occured in your application. Do you have any additional information about this issue?

BTW, I googled the error message on the internet and found this article:
http://social.msdn.microsoft.com/Forums ... ted-memory

Hope it helps!


Hi Catherine
It happens when trying to recognize russian. The rus.traineddata is available for program. I change only the image file and set
dynamicDotNetTwain.OCRLanguage="rus"

Here is the exception description:

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=DynamicDotNetTWAIN
StackTrace:
at Dynamsoft.DotNet.TWAIN.OCR.OCRReader.OCR(Byte[] tiffMemory, Byte[]& pdfContent)
at Dynamsoft.DotNet.TWAIN.DynamicDotNetTwain.OCR(IndexList listImageIndex)
at DynamicOCRWrapper.OCRWrapper.ImplementRecognition(ImageProvider imageProvider) in d:\NET Projects\DynamicOCRWrapper\DynamicOCRWrapper\OCRWrapper\OCRWrapper.cs:line 150
at StaticShell.OCRStaticShell.Recognize(Byte[] imageBytes, ImageType imageType, String language) in d:\NET Projects\DynamicOCRWrapper\Static Access\OCRStaticShell.cs:line 36
at Static_Shell_Sample_WinApp.Form1.btnRecognize_Click(Object sender, EventArgs e) in d:\NET Projects\DynamicOCRWrapper\Static Shell Sample WinApp\Form1.cs:line 44
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Static_Shell_Sample_WinApp.Program.Main() in d:\NET Projects\DynamicOCRWrapper\Static Shell Sample WinApp\Program.cs:line 19
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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1701
Hi Khan,

I checked the exception description but didn't find any useful info. Could you send the relevant code to catherine@dynamsoft.com?

In addition, please let me know the following info:

1. What version of Visual Studio you are using? VS2010, VS2012 or other version?
2. What's version of Dynamic .NET TWAIN you are evaluating? 4.3 trial?
3. What's the target framework of your project? .NET Framework 2.0 or 4.0? Please make sure the target framework is consistent with the DLL you added.

Looking forward to your email.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Fri Aug 30, 2013 4:59 am
Posts: 7
Catherine wrote:
Hi Khan,

I checked the exception description but didn't find any useful info. Could you send the relevant code to catherine@dynamsoft.com?

In addition, please let me know the following info:

1. What version of Visual Studio you are using? VS2010, VS2012 or other version?
2. What's version of Dynamic .NET TWAIN you are evaluating? 4.3 trial?
3. What's the target framework of your project? .NET Framework 2.0 or 4.0? Please make sure the target framework is consistent with the DLL you added.

Looking forward to your email.


1.VS2012
2.Dynamic .NET TWAIN 4.3 Trial
3. 4 or 4.5

My code is a little complicated. You could check this by this way: .dynamsoft provide samples in download package - in the folder "Dynamic .NET TWAIN 4.3 Trial\Samples"
you could open ocr demo solution
Dynamic .NET TWAIN 4.3 Trial\Samples\C# Samples\VS 12\OCRDemo\OCRDemo.sln
and do 2 changes:
1. Change in Form1.cs:
this.dynamicDotNetTwain1.OCRLanguage = "eng";
to
this.dynamicDotNetTwain1.OCRLanguage = "rus";

2. Download and add russian language files from
http://www.dynamsoft.com/Downloads/OCR- ... ckage.aspx

to here:
"Dynamic .NET TWAIN 4.3 Trial\Bin\OCRResources\tessdata"

after this you can build,run and see the problem. I guess your wrapper do not actually support some languages, including russian

Unfortunately I was not smart enougth to check this at the begining.


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1701
Hi Khan,

Please try replacing the old OCR DLL files with the latest ones. Here are the download links:

http://www.dynamsoft.com/download/Suppo ... micOCR.dll
http://www.dynamsoft.com/download/Suppo ... OCRx64.dll

Kindly test it and keep me updated on it.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Fri Aug 30, 2013 4:59 am
Posts: 7
Catherine wrote:
Hi Khan,

Please try replacing the old OCR DLL files with the latest ones. Here are the download links:

http://www.dynamsoft.com/download/Suppo ... micOCR.dll
http://www.dynamsoft.com/download/Suppo ... OCRx64.dll

Kindly test it and keep me updated on it.



Thanks Catherine, now it works. Just your previous dlls was for "old type" traineddata files.

Sorry for late answer, i was in compensatory leave


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1701
Hi Khan,

Thanks for your update. :)

If you have any further questions, please feel free to contact us.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Wed Dec 02, 2015 6:52 pm
Posts: 1
Vincy wrote:
Hi Khan,

Please try replacing the old OCR DLL files with the latest ones. Here are the download links:

http://www.dynamsoft.com/download/Suppo ... micOCR.dll
http://www.dynamsoft.com/download/Suppo ... OCRx64.dll

Kindly test it and keep me updated on it.


Thanks Vincy :D ,saves me a lot of time.


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Moderators: Michael, Vincy


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Copyright © 2016 Dynamsoft | All Rights Reserved
dynamic designed by Dynamsoft team