Smart and powerful OCR tools

Nicomsoft OCR SDK – FAQ


- Is it your own OCR system, or do you use a third-party OCR engine?

While most providers of OCR systems use third-party OCR engines with royalty-based licensing, we have our own OCR engine. We own all intellectual property for our technologies, and we don't have to pay any kind of license fees. As a result, we can offer our OCR engine on a royalty-free basis, which makes our solutions very competitive.

- Which programming languages are supported?

Our OCR engine can be used in all programming languages that can use DLL or COM. Download the evaluation version of the OCR SDK, and check the sample projects: They will show you how to integrate our OCR technology into your software. The OCR SDK contains sample projects for C# WinForms, C# WPF, ASP.NET, VB.NET, VB, C++, Delphi, and C++ Builder.

- How can I integrate NSOCR into my software?

You need to include the "Bin" and "Bin_common" folders of the NSOCR SDK into your software. If your application is x64, also include the "Bin_64" folder. If NSOCR is used as a COM object, you also need to register nsocr.dll using the "Regsvr32" tool during your software installation. For more details, see the "Redistribution of Nicomsoft OCR files" section in the developer's guide. Here is a link to the online version of that section.

- Does the licensed version recognize images better than the trial version?

No, the trial version has the same set of features as the licensed version, and the recognition quality is the same. You can find a full list of the trial version's limitations here.

- How can I use OCR via CREATEOBJECT(ProgID)?

In some programming languages, you can use OCR as a COM object via the CreateObject function, which creates a COM object by its ProgID. The ProgID for the NSOCR COM object is "NSOCRLib.NSOCR.1".

- I rescaled an image before passing it to OCR, but recognition is not good. How come?

By default, NSOCR automatically detects the resolution of the image and rescales it for the best results. If you need to disable auto-rescaling, do not rescale the image manually in your application. Instead, adjust the "ImgAlizer/ScaleFactor" option and set "ImgAlizer/AutoScale"="0". This way, you will get better results, because NSOCR will use its own smart resampling algorithm. NSOCR will also know the original resolution, so it will adjust the recognition algorithms to improve the recognition quality.

- I want to recognize images using several threads, is it possible?

By default, NSOCR detects the number of CPU cores and uses all of them during the OCR process, even when recognizing a single image. You can change this behavior via the "Main/NumKernels" option. However, not all OCR algorithms can be parallelized, and the CPU will not be utilized completely. If you have a lot of images and need to process them as fast as possible, the best way to do it is to process several images at once, using one thread per image. For more details, see "General description of Nicomsoft OCR SDK architecture". Also see the "C# Multithreading Sample" project in the OCR SDK.

- I need to recognize only a part of an image, how can I do it?

Define one or more blocks with the "Img_AddBlock" function before recognition. This way, NSOCR will not detect any text areas automatically, but will recognize the specified image areas only. For more details, please check the sample projects. The code should look like this:

NsOCR.Img_AddBlock(...); //specify area for OCR

- I get the ERROR_NOMEMORY or ERROR_TOOMANYOBJECTS error after processing several images.

It means that you do not release the NSOCR objects (CFG, OCR, IMG, and BLK), but only create them again and again. Please remember to release the objects. For more details, see the "Tips for developers" section of this article.

- Is it possible to make recognition faster?

Yes, in many cases you can increase the recognition speed severalfold. See the "Performance Tips" section in the OCR SDK documentation. Here is a link to the online version of that section.

- I use VS2010 in Windows x64 and get the "BadImageFormatException" exception.

The OCR SDK has both x86 and x64 binaries, and the built-in sample projects work properly in any recent version of Windows x86/x64 and Visual Studio. However, VS2010 has a bug that causes the "BadImageFormatException" exception for "Interop.NSOCRLib" if you use Windows x64 and your .NET project has the "Any CPU" target with the default settings. Read more:
The easiest fix is to change the "AnyCPU" target to "x86". Alternatively, you can add the "<PlatformTarget>AnyCPU</PlatformTarget>" option directly into the project file, as we did for the .NET samples in the NSOCR SDK. For NET 4.0 projects, you can also set the "Embed Interop Types" option to "true", which will prevent the use of the Interop library.

- An image has different contrast levels, and binarization of some blocks is not good.

You can set the "Binarizer/BinTwice" option to "1", and NSOCR will binarize every defined block individually again at the OCRSTEP_OCR step.

- Is rotated or inverted text supported?

Yes, it is. The entire image or some blocks can be inverted, rotated, or mirrored. See "Blk_Inversion", "Blk_Rotation", and "Blk_Mirror" in the developer's guide. For more details, see any "Advanced Sample" project.

- I changed Config.dat manually, and now the Cfg_LoadOptions function returns an error code.

It means that Config.dat has been corrupted. To restore it, you need to reinstall the OCR SDK. Config.dat is a Unicode XML file, so make sure you edit it correctly. For instance, if you want to set the "Main/DisabledChars" option to exclude the "&" character from recognition, you must specify the character as "&amp;". To edit Config.dat properly, you can use the "Cfg_LoadOptions", "Cfg_SetOption", and "Cfg_SaveOptions" functions, which will do all necessary conversions.

- Can I use OCR in C# directly, not via COM?

Yes, you can. Please see the "C# Invoke Sample" project.

- Can I get the position of recognized words and characters?

Yes, you can. Use the "Blk_GetTextRect" and "Blk_GetCharRect" functions.

- I need to recognize handwritten text.

Sorry, our OCR SDK does not support recognition of handwritten text or any fonts that look like handwritten text.

- I need to recognize digits only.

Set the "Main/EnabledChars" option to "0123456789". Edit the "Config.dat" file manually, or use the "Cfg_SetOption" function:

NsOCR.Cfg_SetOption(CfgObj, TNSOCR.BT_DEFAULT, "Main/EnabledChars", "0123456789");

Alternatively, use the "Blk_SetType" function and set the BT_OCRDIGIT block type.

- I cannot scan via TWAIN in Windows x64.

Unfortunately, most scanner makers do not have the x64 TWAIN drivers for their devices, so you cannot use TWAIN in Windows x64. Thankfully, our OCR engine also supports the WIA interface, which can be used in Windows x86 and x64.

- When I use Img_LoadBmpData or Img_LoadFromMemory, it doesn't work.

Most probably, the reason is you use a function that does not match the image data type. In the memory, you can have either data in an image file format, or raw bitmap data. If you save the data to a file that can be opened by an image viewing application, it means you should use the Img_LoadFromMemory function. That function works exactly like Img_LoadFromFile, but loads an image from the memory. The image can be BMP, JPEG, TIFF, etc.
If you have raw bitmap data in the memory and that data doesn't have any headers or compression, use the Img_LoadBmpData function. That function expects raw bitmap data, such as 24-bit RGB values. If you load an image from a file to a .NET image object, save it to a stream, and try to load it via Img_LoadBmpData. If the loading fails, use the Img_LoadFromMemory function instead, since you have data in an image format, not raw RGB bitmap data.
See the OCR SDK sample projects for code that demonstrates the use of each of these two functions.

- How can I find all barcodes in an image?

Set "Zoning/FindBarcodes" to "2", load an image, and recognize it. Here is a (C#) code sample:

//assume reference to NSOCR COM was added
using NSOCR_NameSpace; //Add NSOCR namespace from "NSOCR.cs" file
int CfgObj, OcrObj, ImgObj;
string txt;
NSOCRLib.NSOCRClass NsOCR = new NSOCRLib.NSOCRClass(); //create NSOCR COM object instance
NsOCR.Engine_InitializeAdvanced(out CfgObj, out OcrObj, out ImgObj); //initialize OCR engine, create objects and load configuration
NsOCR.Img_LoadFile(ImgObj, "c:\\sample.bmp"); //load some image for OCR
Cfg_SetOption(CfgObj, TNSOCR.BT_DEFAULT, "Zoning/FindBarcodes", "2"); //find barcodes only
NsOCR.Img_GetImgText(ImgObj, out txt, TNSOCR.FMT_EXACTCOPY); //get text
NsOCR.Engine_Uninitialize(); //release all created objects and uninitialize OCR engine

If you need to recognize only barcodes, it is a good idea to disable such algorithms as autoscaling, deskewing, and garbage and lines removal to improve both recognition quality and performance.

- I cannot process PDF files in my .NET application in Windows x64.

If sample applications from the OCR SDK work properly but your application fails, you need to install the x64 version of GhostScript. The .NET samples in the OCR SDK are compiled to be x86 applications (the "x86" target platform is preset). Probably your application has the "AnyCPU" target platform set by default, so it is an x64 application in Windows x64. Therefore, it uses x64 binaries of the OCR SDK and requires the x64 version of GhostScript. Either install the x64 version of GhostScript, or select the "x86" target platform for your application instead of "AnyCPU".

- Do you have a list of compatible scanners?

Our OCR engine can use the standard TWAIN and WIA interfaces for scanning, so in theory it should work with all scanners that have TWAIN or WIA drivers. However, sometimes the drivers provided by the scanner maker contain bugs. In such a case, the scanner cannot be used with our OCR solution, or can be used with some limitations. This issue is highly dependent on scanner models and driver versions. We do not have a list of compatible scanners as we cannot test all scanners that are available on the market.

- The Blk_GetTextRect and Blk_GetCharRect functions return incorrect coordinates!

For the best recognition, the rescaling and deskewing algorithms are applied to the original image at the OCRSTEP_PREFILTERS step. The functions that you mentioned return the coordinates for the final image. To get the coordinates for the original image, use the "Img_CalcPointPosition" function to convert coordinates.

- I cannot call an OCR function from VBScript or JavaScript!

Probably that is because the function uses one or more parameters by reference. In other words, it returns some values via variables that you pass. VBScript or JavaScript cannot directly call such functions, so you need to use the "Engine_CallFunction" function. For more details, see the developer's guide. Also check the VBScript and JScript samples in the OCR SDK.

- When I do PDF-to-PDF conversion, the output PDF file is much larger than the input PDF file!

Probably the input PDF file contains black-white images and the "Saver/PDF/ImageLayer" option is set to "1", so the output PDF contains a lot of large images. To enable the black-white mode, set the "Main/GrayMode" option to "2". NSOCR will save images as black-white, and the output PDF file will be much smaller.

- I need to get text from a specific block.

Use the "Blk_GetText" function. Here is a (C#) code sample:

//assume reference to NSOCR COM was added
using NSOCR_NameSpace; //Add NSOCR namespace from "NSOCR.cs" file
int CfgObj, OcrObj, ImgObj, BlkObj, i, BlockCnt;
string txt;
NSOCRLib.NSOCRClass NsOCR = new NSOCRLib.NSOCRClass(); //create NSOCR COM object instance
NsOCR.Engine_InitializeAdvanced(out CfgObj, out OcrObj, out ImgObj); //initialize OCR engine, create objects and load configuration
NsOCR.Img_LoadFile(ImgObj, "c:\\sample.bmp"); //load some image for OCR
BlockCnt = NsOCR.Img_GetBlockCnt(ImgObj);
for (i = 0; i < BlockCnt; i++)
NsOCR.Img_GetBlock(ImgObj, i, out BlkObj);
NsOCR.Blk_GetText(BlkObj, out txt, TNSOCR.FMT_EXACTCOPY); //get block text
//do something with block text "txt"
NsOCR.Engine_Uninitialize(); //release all created objects and uninitialize OCR engine

- Can I use my own recognition settings for one or more specific zones?

Yes, you can. Set the custom zone type for that zone, and set the custom settings as described here.

- Can I improve recognition of text printed by matrix printer?

Yes, you can, set "ImgAlizer/Blur" option to "3", "5" or "7".

- I get error 0x80070005 when I register nsocr.dll with regsvr32 tool.

Admin rights are required to register COM objects in Windows, use "Run As Administrator" command.