May I use SimpleOCR to process screen captures?
Sure, but SimpleOCR usually returns poor results with screen captures.
Sure, but SimpleOCR usually returns poor results with screen captures.
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.
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
...
}
void SetOutputWindow(HWND hWnd)
When the output mode OT_WINDOW has been selected with the SetOutputMode function, this function allows you to indicate in which window the text will be sent.
Return Value
None
Parameters
hWnd
A window handler.
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.
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.
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.
void ScanSelect(HWND hWnd)
Lets the user select a given scanner if several scanners are connected to the computer.
Parameters
hWnd
Your application main window handler.
void ScanResolution(int resolution)
Sets the scanning resolution. This function should be called before ScanInit.
Return Value
If the function fails a nonzero error code is returned.
Parameters
resolution
Scanning resolution in DPI. (default = 300 DPI)
int ScanInit(HWND hWnd)
Initializes the image acquisition process.
Return Value
If the function fails a nonzero error code is returned.
Parameters
hWnd
Your application main window handler.
IMG * ScanImg(void)
Acquires a new image. The scanning session should have been initialized with ScanInit.
Return Value
A pointer to the scanned image or NULL if the function fails.
void ScanEnd(void)
Terminate a scanning section.
Return Value
None
void ScanBrightness(int brightness)
Changes scanning brightness
Return Value
None
Parameters
brightness
A value between -1000 (dark) and 1000 (light).
int ScanAvailable(void)
Detects if a scanner is connected to the computer
Return Value
A nonzero value is the scanner is available.
Comments
The connected scanner must be TWAIN compliant and the corresponding 32 bit TWAIN driver must be properly installed
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.
int ScanAndAddImage(SETOFIMG * set)
Acquires a new image and adds it to a previously created image set. The scanning session should have been initialized with ScanInit
Return Value
If the function fails a nonzero error code is returned.
Parameters
set
A set of image of type SETOFIMG
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
... }
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
}
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
...
}
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);
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
...
}
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.
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.
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.
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.