FAQs and how-to articles describing common uses of the SimpleOCR SDK.

SimpleOCR SDK Disclaimer

Information in this document is subject to change without notice and said changes may not be reflected herein. ScanStore.com and its parent company, Meta Enterprises, LLC, may have patents or pending patents applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. The furnishing of this document does not grant you a license to these patents, trademarks, copyrights, or other intellectual property except as expressly provided in a written license agreement from Meta Enterprises, LLC.

2021-01-27T17:42:48-05:00Tags: |

SimpleOCR:SDK Functions – ShrinkImg

IMG * ShrinkImg(IMG * img, int nw, int nh)

Shrinks a bi-level image and returns the result in a grayscale image.

Return Value

A pointer to a new IMG object. If the function fails, the return value is NULL.

Parameters

img

Pointer to an image of type IMG.

nw

Width of the new image.

nh

Height of the new image.

Comments

The original image is left unchanged. If you don’t need it anymore, you have to free it by calling the FreeImg function. This function is mainly useful when you want to display a reduced bi-level image with a good display quality.

Example

IMG *img,img2; 

// Create an IMG 
... 
img2=ShrinkImg(img,640,480); 

if (img2==NULL) 
{
// Error processing 
...
}
2020-12-09T17:39:40-05:00Tags: |

SimpleOCR:SDK Functions – SetOutputMode

void SetOutputMode(int mode)

        Selects the output mode for the OCR engine

Return Value

        None

Parameters

        mode

A value among:

        OT_TEXT

The engine will output only the text.

        OT_RICHTEXT

The engine will output the text and additional information like characters format, characters size, and font type.

        OT_WINDOW

The engine will output only the text directly in a window as it was typed on the keyboard.

2020-11-13T15:34:21-05:00Tags: |

SimpleOCR:SDK Functions – SetLanguage

void SetLanguage(int language, const char* dictDir)

Selects the language used in the text you want to process.

Return Value

None

Parameters

language

A value among:ENGLISH for English language.
FRENCH for French language.
DUTCH for Dutch language.
ENGUK for UK English language.
CUSTOM for Custom dictionary.
NONE for No language selected.

dictDir

The directory where the dictionary files are stored.

Comments

If a language has been selected, the OCR process will use a dictionary in order to improve the OCR results.

2020-11-13T15:29:59-05:00Tags: |

SimpleOCR:SDK Functions – ScanShowUI

void ScanShowUI(int mode)

Indicates if SimpleOCR should use the scanner user interface or not. This function should be called before ScanInit.

Return Value

If the function fails a nonzero error code is returned.

Parameters

mode

The selected mode.

nonzero

Use user interface (default).

zero

Don’t use the user interface.

2020-11-13T15:26:37-05:00Tags: |

SimpleOCR:SDK Functions – ScanAutoBright

void ScanAutoBright(int automode)

Selects “Autobright” mode and lets the scanner determines an optimal brightness level. (Recommended)

Return Value

None

Parameters

automode

Mode:

nonzero value

Select the “autobright” mode

zero value

Unselect the “autobright” mode. In this case, you may select the brightness level by using ScanBrightness.

2020-11-12T15:44:44-05:00Tags: |

SimpleOCR:SDK Functions – SaveMultipleImg

void SaveMultipleImg(const char * filename, SETOFIMG * set)

Saves an image from a TIFF file.

Return Value

If the function fails a nonzero error code is returned.

Parameters

filename

Name of the TIFF file you want to create.

set

Image to be saved.

Comments

Example

SETOFIMG *set; 

// Creates a set of images 
... 

if (SaveMultipleImg("foo.tif",set)) 
{ // error processing 
  ... }
2020-11-11T19:55:20-05:00Tags: |

SimpleOCR:SDK Functions – SaveImg

int SaveImg(const char * filename, const IMG * img)

Saves an image to a TIFF file.

Return Value

If the function fails a nonzero error code is returned.

Parameters

filename

Name of the TIFF file you want to create.

img

A pointer to the image to be saved.

Comments

Example

IMG *img; 

// Create an IMG 
... 

if (SaveImg("foo.tif",img)) 
{
//error processing
}
2020-11-11T19:48:45-05:00Tags: |

SimpleOCR:SDK Functions – RotateImg

int RotateImg(IMG * img, int angle)

Rotates an image.

Return Value

If the function fails a nonzero error code is returned.

Parameters

img

Pointer to an image of type IMG.

angle

Rotation angle, given in degrees.

Comments

Example

IMG *img; 

if (RotateImg(img,180)) 
{
//error processing 
...
}
2020-11-11T19:39:40-05:00Tags: |

SimpleOCR:SDK Functions – ResizeImg

IMG * ResizeImg(IMG * img, int nw, int nh)

Resizes an image.

Return Value

A pointer to a new IMG object. If the function fails, the return value is NULL.

Parameters

img

Pointer to an image of type IMG.

nw

Width of the new image.

nh

Height of the new image.

Comments

The original image is left unchanged. If you don’t need it anymore, you have to free it by calling the FreeImg function.

Example

IMG *img,img2; 

// Create an IMG 
... 
img2=ResizeImg(img,640,480); 

if (img2==NULL) 
{
// Error processing 
...
} 

// Use the resized Image 
... 

// Free it 
FreeImg(img2);
2020-11-11T19:35:18-05:00Tags: |

SimpleOCR:SDK Functions – ReplaceImage

int ReplaceImage(SETOFIMG * set, int index, IMG * image)

Replaces an image in a set of image at a given position.

Return Value

If the function fails, a nonzero value is returned.

Parameters

set

A set of images of type SETOFIMG.

index

Position of the replaced image, counted from 0.

image

A pointer to the new image.

Comments

The replaced image is automatically freed.

Example

SETOFIMG *doc; 
IMG *img; 
int nb; 

// Creates an image in img 
... 

// Creates a set 
... 

// Replace the third image 
if (ReplaceImage(set,2,img)) 
{
// error processing 
...
}
2020-11-11T19:30:10-05:00Tags: |

SimpleOCR:SDK Functions – OCRLimitCharsTo

void OCRLimitCharsTo(const char * charsToLimit)

Sets the characters that the OCR output will be limited to.

Return Value

None

Parameters

charsToLimit

string containing the characters that the OCR output will be limited to

Comments

There are default limited character sets that are defined as follows:#define LC_NUMERIC 1 only numbers
#define LC_ALPHABETIC 2 only letters
#define LC_ALPHANUMERIC 3 no punctuation
#define LC_UCASE 4 all uppercase
#define LC_LCASE 5 all lowercase
#define LC_NONNUMERIC 6 no numbers

Passing the function a string of zero length, a NULL value, or a zero will turn off the limiting of characters.

2020-11-11T19:23:11-05:00Tags: |

SimpleOCR:SDK Functions – OCRSetTemplate

void OCRSetTemplate(const char * theTemplate)

Sets the template for use in template matching during the OCR process.

Return Value

None

Parameters

theTemplate

String containing the template to use in OCR template matching.

Comments

The templates consist of the following:# – Number
A – Letter
X – Any character
? – Optional character. – Use at end of template.
Other – Must match character

Providing a string of zero length, a NULL value, or the number zero will turn off template matching Template recognition can be increased by limiting the character set to only those characters that will appear in the strings matched by the template.

2020-11-11T19:19:13-05:00Tags: |

SimpleOCR:SDK Functions – OCRSetProgressHandler

OCRProgressHandler OCRSetProgressHandler(OCRProgressHandler handler)

When the OCR engine processes a document, a user defined function of type OCRProgressHandler, is called several times.

Return Value

Previously selected progress handler.

Parameters

handler

New OCR Progress handler function.

Comments

An OCRProgressHandler has the following form:

int AProgressHandler(int percent);

with percent, the percentage of the job completed at the time of the call. This value is between 0 and 100.

Defining such a function allows an application to display a progress bar. With this function, it’s also possible to interrupt the OCR process. If the progress handler returns a non zero value, the OCR process is stopped.

2020-11-11T19:14:35-05:00Tags: |

SimpleOCR:SDK Functions – OCRSetOutputCharHandler

OCROutputCharHandler OCRSetOutputCharHandler(OCROutputCharHandler handler)

When the output mode is O

M_TEXT or OM_RICHTEXT, a user defined function of type OCROutputCharHandler will be called by the OCR engine for each “real character” (i.e.: not for EOLs and Spaces). This function is called immediately after OCROutputHandler is called with the event OT_TEXT.

Return Value

Previously selected output handler.

An OCROutputCharHandler has the following form:

void AnOCRCharHandler(int ch, int conf, int left, int top, int width, int height);

ch

ASCII code of recognized character.

conf

Confidence level of the recognized character. Values can be 0-100. The higher the confidence – the engine is more sure about the recognized character.

left, top

coordinates (in pixels) of character in original image.

width, height

width and height in pixels of recognized character.

2020-11-11T19:09:58-05:00Tags: |

SimpleOCR:SDK Functions – OCRSetOutputHandler

OCROutputHandler OCRSetOutputHandler(OCROutputHandler handler)

When the output mode is OM_TEXT or OM_RICHTEXT, a user defined function of type OCROutputHandler will be called by the OCR engine for each “OCR event”.

Return Value

Previously selected output handler.

Parameters

handler

New OCR Output handler function.

Comments

If the output mode is OT_TEXT, OCR events among OT_PROP, OT_ITAL, OT_UNDS, OT_SIZE, OT_HILT and OT_BITM are not sent to the output hander.

An OCROutputHandler has the following form:

void AnOCRHandler(int event, int param);

with event, the code of the “OCR event” and param a value associated with the event.

The OCR events are:

OT_TEXT

A character has been recognized. param contains the ASCII code of the recognized character.

OT_PROP

The font type has changed (proportional or non proportional font). param is nonzero if the font is proportional.

OT_ITAL

Switches italic mode on or off. param is nonzero if the following characters are italic.

OT_UNDS

Switches underscored mode on or off. param is nonzero if the following characters are underscored.

OT_SIZE

Changes the character size. param contains the font size for the following characters.

OT_HILT

Changes the character color.
If param contains 1, the following word is not in the dictionary. If param contains 2, the following word has not been well recognized.

OT_ENDL

An end of line has been reached.

OT_ENDZ

An end of text area has been reached.

OT_BITM

An image […]

2020-11-11T18:59:44-05:00Tags: |
Go to Top