Leaper WaferScan Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILOCR Interface Reference

This interface provide functionalities of character segmentation, recognition and verification. More...

Inheritance diagram for ILOCR:
ILObject LOCR

Public Member Functions

LPVErrorCode Detect (ILImage *img, ILRegion *region, ILOCRResult **results)
 
LPVErrorCode DetectAndVerify (ILImage *img, ILRegion *region, ILOCRResult **results)
 
LPVErrorCode Segment (ILImage *img, ILRegion *region, ILOCRResult **results)
 
void SetCharSize (int w, int h, double wTolerance, double hTolerance)
 
void SetCharSkew (double skewLB, double skewUB)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

double AspectRatioChange [get, set]
 The resize ratio compared with the standard aspect ratio in the font database, in range 0.5 ~ 1.5. By default, it's 1 means no change.
 
BOOL AutoDotPrint [get, set]
 Whether to turn on automatic dot-print detection. By default, it's off.
 
int CharHeightLB [get, set]
 The lower bound of the character's estimated height, at least 1 pixel.
 
int CharHeightUB [get, set]
 The upper bound of the character's estimated height, should be larger than or equal to the lower bound.
 
double CharSkewLB [get, set]
 The lower bound of the italic character's skew int angle, in -60 ~ 60 degree.
 
double CharSkewUB [get, set]
 The upper bound of the italic character's skew int angle, should be in -60 ~ 60 degree and larger than or equal to the lower bound.
 
int CharWidthLB [get, set]
 The lower bound of the character's estimated width, at least 1 pixel.
 
int CharWidthUB [get, set]
 The upper bound of the character's estimated width, should be larger than or equal to the lower bound.
 
double DotGap [get, set]
 The maximum distance between two nearby dots' centers. By default, it's 0 which means we'll decide it on the fly based on the distributions of all the distances.
 
BOOL DotPrint [get, set]
 Whether to segment as the dot-print character. By default, it's no.
 
double DotSize [get, set]
 The average area of individual dots, used to determine whether a foreground object is the character dot or some noisy fragment. By default, it's 0 which means we'll decide it on the fly based on the distributions of all foreground objects.
 
ILFontDatabase FontDatabase [get, set]
 The associated font database.
 
int FragmentThreshold [get, set]
 The maximum area of object that could be treated as fragment, then it will be merged to neighbors to form a valid character. By default, it's 0 which means we'll decide it on the fly based on the distributions of all foreground objects.
 
int NoiseThreshold [get, set]
 The minimum area of valid character or fragment in pixel. By default, it's 0 which means we'll decide it on the fly based on the distributions of all foreground objects.
 
LPVPolarity Polarity [get, set]
 The object polarity of the characters from the background.
 
LPVOCRSegmentFlags SegmentFlags [get, set]
 The extra segmentation flags to control the line and character segmentation behavior.
 
wchar_t UnknownPlaceholder [get, set]
 The place holder for unknown characters. By default, it's the question symbol '?'.
 
LPVOCVFlags VerifyFlags [get, set]
 The verification flags to control which parts contribute to the verification score.
 

Detailed Description

This interface provide functionalities of character segmentation, recognition and verification.

The OCR tool is used for vision-based character segmentation, recognition and verification. It is supported to extract multiple lines of text by one scanning. It's also capable to separated ligatures in line and sticky lines, which is a common case in laser-printed labels. Recognition and verification is processed based on the specified font database and the trained character models inside it.

To use this interface, you should create a LOCR object.

Example Code

Member Function Documentation

◆ Detect()

LPVErrorCode Detect ( ILImage img,
ILRegion region,
ILOCRResult **  results 
)

Segment and recognize the lines and characters from the given image and region.

Parameters
[in]img The input image.
[in]regionThe input region. For the rotated rectangle region, the region's angle is used as the main direction of the text line. For the others, the main direction is the image's x axis.
[out]resultsOutput the segmentation and recognition result.
Return values
errorReturn error code if anything is wrong.
See also
Segment(), DetectAndVerify()

◆ DetectAndVerify()

LPVErrorCode DetectAndVerify ( ILImage img,
ILRegion region,
ILOCRResult **  results 
)

Segment, recognize and verify the lines and characters from the given image and region.

Parameters
[in]img The input image.
[in]regionThe input region. For the rotated rectangle region, the region's angle is used as the main direction of the text line. For the others, the main direction is the image's x axis.
[out]resultsOutput the segmentation, recognition and verification result.
Return values
errorReturn error code if anything is wrong.
See also
Segment(), Detect()

◆ Segment()

LPVErrorCode Segment ( ILImage img,
ILRegion region,
ILOCRResult **  results 
)

Segment the lines and characters from the given image and region.

Parameters
[in]img The input image.
[in]regionThe input region. For the rotated rectangle region, the region's angle is used as the main direction of the text line. For the others, the main direction is the image's x axis.
[out]resultsOutput the segmentation result.
Return values
errorReturn error code if anything is wrong.
See also
Detect(), DetectAndVerify()

◆ SetCharSize()

void SetCharSize ( int  w,
int  h,
double  wTolerance,
double  hTolerance 
)

Set the character's estimated size range.

Parameters
[in]wThe estimated width.
[in]hThe estimated height.
[in]wToleranceThe tolerance of width in percentage. It generates the width bounds as \( w /times (1 - wTol \%) ~ w /times (1 + wTol \%) \) .
[in]hToleranceThe tolerance of height in percentage. It generates the height bounds as \( h /times (1 - hTol \%) ~ h /times (1 + hTol \%) \) .

◆ SetCharSkew()

void SetCharSkew ( double  skewLB,
double  skewUB 
)

Set the skew angle range of the italic characters, in -60 ~ 60 degree.

Parameters
[in]skewLBThe lower skew angle bound
[in]skewUBThe upper skew angle bound