ALOCR Ver 1.0 reference manual

Table of Contents
  1. Constants and Structures
    1. Character Control
    2. Recognition Result

  2. Details
    1. Types of Pattern Dictionaries
    2. Construction of Pattern Dictionary Classes
    3. User Dictionary Management
    4. Dictionary Class:CJocrDict Reference
    5. Construction of Pattern Classes
    6. Feature Calculation of Patterns
    7. Pattern Class:CJocrPattern Reference
    8. Construction of Single Character Recognition Classes
      Updated on November 6, 2000 In addition to the license code, the license code file can now be specified.
    9. Single Character Recognition
    10. Single Character Recognition Class:CJocrRecognize Reference
    11. Construction of Line Recognition Classes
    12. Line Recognition
    13. Line Recognition Class:CJocrLine Reference
    14. Language Processing with Line Recognition Class:CJocrLang Reference
    15. Paragraph Recognition Class:CJocrBlock Reference
      Updated on July 31, 2002 Skew can now be specified for paragraphs. It is possible to recognize italic text only for single-line text.
      Updated on August 31, 2005 Addition of new dictionaries
      Updated on August 31, 2005 New version recognition method. Significant improvement in recognition rate compared to the conventional method
      Updated on November 30, 2022 Deep learning support. Support for color image and grayscale image recognition. Significant improvement in recognition rate compared to the conventional method


  3. Sample Programs
    1. VC++ Sample Project


manual homepage

user's manual


reference manual

1.Constant and Structure


1.1 Character Type Control

Character type is specified by logical OR of character type flags. Character type flags are defined in the header file ocrdef.h. The user of the library can specify the following flags. Character type is specified in the mrecognize member function of the character recognition class and the line recognition class. Character type is specified by two arguments in mrecognize. The second argument specifies semantic constraints such as ASCII symbols and file name symbols.

Character type flags that can be specified as the first argument of mrecognize

Normal symbolSYMBOL_ETC!:”’‘?^_ ̄&#@´ `‘“
Number symbolSYMBOL_NUMBER=+*<>/¥$%±×÷≠≦≧
Middle dotSYMBOL_NAKAGURO
Minus signSYMBOL_MINUS
CommaSYMBOL_COMMA
PeriodSYMBOL_PERIOD
Round bracketsSYMBOL_PAREN()
BracketsSYMBOL_BRACE{}[]--〔〕「」『』【】
Punctuation marksSYMBOL_KUTOTEN、。
CircleSYMBOL_MARU
Extended barSYMBOL_NOBASBO
Arabic numeralsCHAR_NUMBER0~9
Uppercase alphabetsCHAR_ALPHABET_CAPITALA-Z
Lowercase alphabetsCHAR_ALPHABET_SMALLa-z
Uppercase katakanaCHAR_KATAKANA_CAPITALア-ン
Lowercase katakanaCHAR_KATAKANA_SMALLァ-ヶ
Uppercase hiraganaCHAR_HIRAGANA_CAPITALあ-ん
Lowercase hiraganaCHAR_HIRAGANA_SMALLぁ-ょ
Kanji numeralsCHAR_KANJI_NUMBER一二三四五六七八九十百千万億兆
Kanji charactersCHAR_KANJI 

Contents


Possible flags that can be specified as the second argument of the mrecognize method:

Ascii symbolsASCII_CHARSET
File nameFILE_CHARSET

The second argument is specified to further narrow down the character type specified in the first argument. For example, when using only ASCII symbols (=+*<>/$%±×÷≠≦≧) from numerical symbols, you would specify:

mrecognize(SYMBOL_NUMBER, ASCII_CHARSET);

Specifying alphabets and Arabic numerals will also include two-digit English letters and numbers such as "WA" or "12" as recognition targets. Two-digit alphanumeric characters will improve recognition rates for mixed recognition of kanji, kana, and alphanumeric characters, but it will have a reverse effect when it is known that the recognition target is only alphanumeric. In that case, you would specify:

mrecognize(CHAR_NUMBER | CHAR_ALPHABET_CAPITAL | CHAR_ALPHABET_SMALL, ASCII_CHARSET);
Also, the following macros are defined for character sets:

Macro ConstantsDescriptionDefinition
CHAR_SET_SYMBOLSymbols(SYMBOL_ETC | SYMBOL_NUMBER | SYMBOL_NAKAGURO | SYMBOL_MINUS | SYMBOL_MARU | SYMBOL_NOBASBO)
CHAR_SET_KAKKOBrackets(SYMBOL_PAREN | SYMBOL_BRACE)
CHAR_SET_TERMINALPunctuation marks(SYMBOL_PERIOD | SYMBOL_COMMA | SYMBOL_KUTOTEN)
CHAR_SET_ALPHABETAll alphabets(CHAR_ALPHABET_SMALL | CHAR_ALPHABET_CAPITAL)
CHAR_SET_HIRAGANAHiragana(CHAR_HIRAGANA_CAPITAL | CHAR_HIRAGANA_SMALL)
CHAR_SET_KATAKANAKatakana(CHAR_KATAKANA_CAPITAL | CHAR_KATAKANA_SMALL)
CHAR_SET_KANJIAll kanji characters(CHAR_KANJI | CHAR_KANJI_NUMBER)
CHAR_SET_ALLAll character types(CHAR_SET_SYMBOL | CHAR_SET_KAKKO | CHAR_SET_TERMINAL | CHAR_NUMBER | CHAR_SET_ALPHABET | CHAR_SET_HIRAGANA | CHAR_SET_KATAKANA | CHAR_SET_KANJI)

In general, the character types to be recognized are specified by taking the logical sum of these macros.

Table of Contents


1.2 Recognition Result

Table of Contents
The recognition result is managed by the following structure.
Members without comments are undisclosed internal information.
// Pattern bounding rectangle
typedef struct {
    short       x1;         // Top left x coordinate of the pattern
    short       y1;         // Top left y coordinate of the pattern
    short       x2;         // Bottom right x coordinate of the pattern
    short       y2;         // Bottom right y coordinate of the pattern
} OCRRect;
// Recognition candidate
typedef struct {
    char*           code;       // Pointer to the pattern string
    unsigned char   score;      // Confidence level
    unsigned char   filler[3];  // padding
} Candidate;
//////////////////
// OCR result structure
// 128 bytes fixed
typedef struct {
    Candidate       cand[MAX_CAND]; // Candidate data MAX_CAND == 10 80 bytes
    OCRRect         area;           // Recognized area 8 bytes
    long            fieldtype;
    unsigned long   chartype;       // Character type of the recognition result
    unsigned long   maskchartype1;
    unsigned long   maskchartype2;
    unsigned long   space;          // Number of spaces following the characters in a line recognition
    unsigned char   cgravx;
    unsigned char   cgravy;
    unsigned char   morph;
    unsigned char   size;
    char            newcand[KEYSIZE_MAX];
} OCRResult;

If the recognition result is

OCRResult ocrresult;

ocrresult.cand[0] through ocrresult.cand[9] are candidates for the recognition result, and ocrresult.cand[0].code can be considered as the string representing the recognition result of the first candidate, which is the pattern.

Among the members of OCRResult, the most important member is the Candidate array that represents the string of the recognition result. The ALOCR library includes a maximum of 10 candidates in OCRResult.

The code member of the Candidate structure points to the string of the recognition result. In most cases, the code points to a single kanji character string. The content of this code points to a string loaded from a dictionary (or registered in a user dictionary). Therefore, please be careful when deleting the dictionary class, as the pointer may not be guaranteed.

Candidates are the first and second candidates for each pattern. Please note that joining the second candidate does not lead to the string recognition result of the second candidate.

If the number of candidates is less than 10, the destination of the code is not NULL but "". Furthermore, if the score is 0, it indicates that there are no candidates.

The score member of the Candidate structure indicates the confidence level of the candidate character. The confidence value ranges from 0 to 100. In the case of 0, it indicates that there are no candidates. Confidence levels for candidates range from 1 to 100, and the closer it is to 100, the more reliable it is as a recognition result.

Normally, the confidence level of the first candidate is 60 or higher, and if it is lower, there is a high possibility that the recognition did not go well.

Among the members of OCRResult, the area member indicates the enclosing rectangle of the recognized pattern (character). The top left of the image is the origin, with the right direction being the positive direction of the x-coordinate and the downward direction being the positive direction of the y-coordinate.

typedef struct {
	short 		x1;			// Top left x-coordinate of the pattern
	short 		y1;			// Top left y-coordinate of the pattern
	short 		x2;			// Bottom right x-coordinate of the pattern
	short 		y2;			// Bottom right y-coordinate of the pattern
} OCRRect;

The other members of OCRResult are the character type of the string pointed by cand[0].code. space represents the spacing between characters in a line recognition (the number of spaces when a kanji character is converted to two spaces). The other members are undisclosed internal information.


Table of Contents


2.Each Section


2.1 Types of Pattern Dictionary

Table of Contents
There are three types of pattern dictionaries in terms of format:

  1. Basic Dictionary Format (2)
  2. Optional Dictionary Format (any number)
  3. User Dictionary Format (0 or 1)
To recognize, two basic dictionaries are always necessary. Other dictionaries are not required. Optional dictionaries are also called differential dictionaries because they contain differential information with basic dictionaries. Differential dictionaries without combining basic dictionaries have no meaning.

Basic Dictionaries
Dictionary NameRecord File NameKey File NameContent
systemsystem.dbssystem.keyRequired
systemfatsystemfat.dbssystemfat.keyRequired
Optional Dictionaries (Differential Dictionaries)
diff0diff0.dbfdiff0.kefKaisho Font
diff1diff1.dbfdiff1.kefBlurry Characters
diff2diff2.dbfdiff2.kefSquished Characters
diff3diff3.dbfdiff3.kefNumbers
diff4diff4.dbfdiff4.kefAlphabets
diff5diff5.dbfdiff5.kefHiragana
User Pattern Dictionary
Any name
Dictionary Newly Added on August 31st, 2005
Entries of the basic dictionary itself have been added with 54 additional second-level kanji. Additionally, information about radical, phonetic, phonetic-semantic compound has been added.
The effect of improving recognition rate of alphanumeric kana can be achieved by kana/ninja001.
If "日" looks similar to "II" and is heavily blurry, adding optblur and blur can improve the recognition.
If "書" looks like "■" with added fur, adding optblot and blot can improve the recognition.
The general document recognition API to be released within the year 2005 will include assessment of blurriness and squishiness of documents.
Newly added pattern dictionaries
kanakana.dbfkana.kefAddition of Hiragana, Katakana
optbluroptblur.dbfoptblur.kefSevere Blurry Characters 1
blurblur.dbfblur.kefSevere Blurry Characters 2
optblotoptblot.dbfoptblot.kefSevere Squished Characters 1
blotblot.dbfblot.kefSevere Squished Characters 2
ninja001ninja001.dbfninja001.kefAddition of Alphanumeric Characters

To achieve a reasonably practical recognition rate, we recommend using the basic dictionary plus the dictionaries diff3, diff4, and diff5. The diff0 font is only used for special documents such as business cards, so it is not usually included. Adding diff1 and diff2 can have a significant effect if the image quality of the text to be recognized is poor.

About User Dictionary
The format of the user dictionary is the same as the optional dictionary, but the only difference is that the image of the pattern itself is also stored for reference. Only one user dictionary can be used per dictionary class instance.

Also, within the lifetime of one dictionary class instance, you can usually only register a maximum of 1024 patterns. If you need to register more than 1024 patterns, you need to delete the instance first, and then generate and initialize it again.
In addition, since the user dictionary is always managed exclusively as long as an instance exists, only one user dictionary can be used on one machine at a time. To share a user dictionary among multiple instances of recognition classes, you need to share one dictionary class instance.

The maximum number of records in one dictionary is 8192. A typical dictionary contains records corresponding to several hundred to several thousand characters.
The larger the size of the dictionary, the longer it takes for recognition.
By the way, as of now (June 1999), the total number of records combining all the basic and optional dictionaries is about 10,000.

Table of Contents


2.2 Construction of Pattern Dictionary Class

Table of Contents
Construction of the basic dictionary class is done in the following order:
  1. Creation of an instance
  2. Setting of the basic dictionary name, optional dictionary name, and user dictionary name
  3. Loading of the dictionary
A maximum of JOCRMAXDICT dictionaries can be set by combining the basic dictionary and the user dictionaries. JOCRMAXDICT is currently defined as 12. If the number of dictionaries exceeds JOCRMAXDICT, an error will only occur when it is configured. If it is troublesome, you can ignore the return value.

During the loading of the dictionary, the file is opened, read, and dynamically allocated to memory.

FILE_OPEN_ERRORFile not found.
The file is locked (the dictionary is currently in use).
An instance using the same user dictionary already exists.
Another instance is loading the same system dictionary.
FILE_READ_ERRORRead error (the dictionary may be corrupted).
FILE_SEEK_ERRORSeek error (the dictionary may be corrupted).
MEMORY_SHORTAGEMemory shortage.
FATAL_ERRORFatal error (no dictionary records could be loaded).

One of the above errors may occur.
The error codes are defined in the header file "errcode.h". In file-related errors (FILE_...._ERROR), files other than the one in error are successfully loaded and processing can continue (it is usually recommended to stop processing and eliminate the cause of the error). For MEMORY_SHORTAGE and FATAL_ERROR, processing should not continue after deleting the instance. Instead, immediate saving of data and termination processing should be performed.


Code example for constructing a basic dictionary class

#include	"ocrdef.h"
#include	"ocrco.h"
#include	"cjocrstock.h"
#include	"cjocrdict98.h"
#include	"errcode.h"

.....

// 1...Create an instance of the dictionary class
  	CJocrDict* pjocrdict = new CJocrDict;
// 2...Set up the basic dictionary
	pjocrdict->msetsystemdict("\\dic\\feature\\system");
	pjocrdict->msetsystemdict("\\dic\\feature\\systemfat");
// 3...Set up the optional dictionary
	pjocrdict->msetdiffdict("\\dic\\feature\\diff1");
	pjocrdict->msetdiffdict("\\dic\\feature\\diff2");
	pjocrdict->msetdiffdict("\\dic\\feature\\diff3");
	pjocrdict->msetdiffdict("\\dic\\feature\\diff4");
	pjocrdict->msetdiffdict("\\dic\\feature\\diff5");
// 5...Set up the user dictionary (optional)
	m_pJocrDict->msetuserdict("\\dic\\feature\\userpat");
// 6...Load the dictionary
	i1 = pjocrdict->mloaddict();
	if(i1 < 0) {
		Error (defined in errcode.h)
		FILE_OPEN_ERROR	The dictionary could not be found
		FILE_READ_ERROR	The dictionary could not be read
		FILE_SEEK_ERROR	Unable to seek to the dictionary record
		MEMORY_SHORTAGE	Out of memory (no further processing)
		FATAL_ERROR		Unrecoverable error (no further processing)
	}

......Recognition, registration, deletion, reference

// Delete the instance
	delete pjocrdict;

Table of Contents


2.3 User Dictionary Management

Table of Contents
The dictionary class uses the CNgkDatabase class library, which is a high-speed ISAM file management program. The key of each record is a string of length up to KEYSIZE_MAX (defined as 16 in ocrdef.h). In most cases, it is a two-byte, single-character kanji.

To read or delete a record, it seeks and then calls the corresponding function. To register a record, it simply calls the registration function, which also performs the seek operation.

There are two types of seek operations: sequential access to the first record, previous or next records, or the last record, and random access using the key (string).

Furthermore, after constructing an instance of the CJocrDict class once, only up to 1024 registrations are allowed. If you want to register more than that, you need to delete the instance of CJocrDict and reconstruct it. This inconvenience is the cost of creating a table for fast access after loading the pattern dictionary in the CJocrDict class.

When constructing a large dictionary in batches, it is possible to remove the limit of 1024 and set it within the range of 1 to 65000.

  1. Seek and register
    Assuming pattern is an instance of the CJocrPattern class, after setting the image of the kanji "漢" as the pattern and calculating its features (calling pattern->mcalcall(...)),
    	int i1 = pjocrdict->mput("漢",pattern);
    	if(i1 < 0) {
    		Error;
    		FILE_SEEK_ERROR
    		FILE_WRITE_ERROR
    	}
    
  2. Seek and delete
    To delete a record corresponding to the key "漢" from the user dictionary, first seek and then call the deletion function as follows.
    	int i1 = pjocrdict->mseek("漢");
    	if(i1 < 0) {
    		Error;
    	}
    	if(i1 == 1) {
    		// Delete
    		i1 = pjocrdict->mdel();
    		if(i1 < 0) {
    			Error;
    		}
    	}
    
  3. Seek to the next record and get the key and the image of the pattern.
    	int i1 = pjocrdict->mseeknext();
    	// keysize is a variable used for input and output
    	// It represents the maximum read buffer size when inputting
    	// and the actual read size when outputting
    	unsigned long	keysize = KEYSIZE_MAX;
    	char			keybuffer[KEYSIZE_MAX];
    	if(i1 == 1) {
    		i1 = pjocrdict->mgetkey(keysize,keybuffer);
    		if(i1 < 0) {
    			Error;
    		}
    		else {
    			// REG_FONT_SIZE is the normalized font size in bytes
    			// It is resized and saved as REG_FONT_SIZE during user dictionary registration
    			// In ALOCR Ver.1.0, the normalized font is 48x48 pixels, which is 288 bytes
    			// REG_FONT_WIDTH....48
    			// REG_FONT_HEIGHT....48
    			// REG_FONT_SIZE....48*48/8(8 pixels = 1 byte)
    			// recordsize is a variable used for input and output
    			// It represents the maximum read buffer size when inputting
    			// and the actual read size when outputting
    			unsigned long	recordsize  = REG_FONT_SIZE;
    			char			record[REG_FONT_SIZE];
    			i1 = mgetpattern(recordsize,record);
    			if(i1 < 0) {
    				Error;
    			}
    			// The obtained pattern is a bitmap of REG_FONT_WIDTH × REG_FONT_HEIGHT pixels.
    		}
    	}
    	else if(i1 == 0) {
    		No more records;
    	}
    	else {
    		Error;
    	}
    

Table of Contents


2.4 Dictionary Class Reference

Table of Contents
Class NameCJocrDict
Header Fileocrdef.h
ocrco.h
cjocrstock.h
cjocrdict98.h
errcode.h
  1. Setting up the base dictionary
  2. Setting up the option dictionary (difference dictionary)
  3. Setting up the user dictionary
  4. Loading the set dictionaries
  5. Seeking
  6. Getting the pattern registration key
  7. Getting the pattern image
  8. Registration
  9. Deletion
  10. Getting the number of records
  11. Changing the upper limit of user dictionary registrations

Table of Contents


2.5 Constructing Pattern Classes

Table of Contents
Class NameCJocrPattern
Header Fileocrdef.h
ocrco.h
cjocrpat98.h
errcode.h
The minimum unit recognized as a single string key is called a pattern. Usually, 1 character = 1 pattern, but in ALOCR, this restriction is lifted. It allows a single pattern to have more than 1 character, as shown below.

A maximum of 15 bytes of string can be assigned to a single pattern.

	// 1...Create an instance of the pattern class
	CJocrPattern* pattern = new CJocrPattern;
	// 2...Allocate memory
	i1 = pattern->mallocmemory();
	if(i1 < 0) {Display error message; delete pattern;}

	.....

	delete pattern;


Table of Contents


2.6 Pattern Feature Calculation

Table of Contents
The Pattern class is a class for cropping, normalizing, and calculating features of pattern images. Cropping, normalizing, and feature calculation are performed with the following member functions. The image data is defined as follows:

typedef struct {
	unsigned char* 	top;		// Address of the start of the image data
	short			width;		// Width of the image data (in byte boundaries, in pixels)
	short			height;		// Height of the image data (in pixels)
} OCRBuffer;
typedef struct {
	short		x1;			// Top-left x-coordinate of the pattern
	short		y1;			// Top-left y-coordinate of the pattern
	short		x2;			// Bottom-right x-coordinate of the pattern
	short		y2;			// Bottom-right y-coordinate of the pattern
} OCRRect;

Cropping, normalizing, and feature calculation of the pattern image are called with the following member function. For the third argument, specify 0 when the background is bit 0, and 1 when the background is bit 1.

pattern->mcalcall(OCRBuffer* pocrbuffer,OCRRect* prect,0);


Table of Contents


2.7 Pattern Class: CJocrPattern Reference

  1. Feature Calculation


Table of Contents


2.8 Building the Single Character Recognition Class

Contents
Class NameCJocrRecognize
Header Fileocrdef.h
ocrco.h
cjocrrec98.h
errcode.h

This is a class that manages the recognition-related functions and the work buffer for recognition. As a member variable of the class, instances of the dictionary class and the pattern class are set, and the main process is to compare the feature vectors of the pattern class and the dictionary class.

Pattern recognition is basically a very simple process of outputting the key of the dictionary class record that has the feature vector closest to the feature vector of the pattern class.

However, because there are a large number of recognition targets, it is not practical to calculate them directly within a reasonable processing time. Various techniques for speeding up the process have been implemented.

    // 1...Create an instance of the recognition class
    // Construct an instance by specifying a 20-digit code supplied by the library license distributor.
// Updated on November 6, 2000 // Alternatively, specify the path to a license code file supplied by the library license distributor.
CJocrRecognize* precognize = new CJocrRecognize("ABCDEFGHJKLMNPQ23456"); // For license code files CJocrRecognize* precognize = new CJocrRecognize("C:\\Program Files\\Foo\\jocr.kcd"); // 2...Pattern setting // Let pattern be an instance of the CJocrPattern class // .....Generate and initialize the pattern precognize->msetpatter(pattern); // 3...Dictionary setting // Let pjocrdict be an instance of the CJocrDict class // .....Generate and initialize pjocrdict precognize->msetdict(pjocrdict); // 4...Memory allocation i1 = precognize->mallocmemory(); if(i1 < 0) { MEMORY_SHORTAGE....Insufficient memory (defined in errcode.h) Display error message;delete pattern; } .... Repeat single character recognition process .... delete pattern;

Contents


2.9 Character Recognition

Table of Contents
You can specify the type of character to recognize as an argument. The main types of characters are:
These are defined in ocrdef.h. For more details, please refer to.....
    pattern->mrecognize(CHAR_SET_ALL);
    // Get recognition result
    // For OCRResult, please refer to section 2-2 in the reference manual.
    OCRResult aresult;
    mgetresult(&aresult);

Table of Contents


2.10 Character Recognition Class: CJocrRecognize Reference

  1. Initialization
  2. Recognition, Identification, and Retrieval of Recognition Results

Table of Contents


1. Building the Line Recognition Class

Table of Contents

The line recognition class only supports a coordinate system with the positive Y-axis pointing downwards. The coordinate system with the positive Y-axis pointing upwards is only supported by the paragraph recognition class.

Class NameCJocrLine
Header Fileocrdef.h
ocrco.h
cjocrline98.h
errcode.h
	// 1...Create an instance of the line class
  	CJocrLine* pjocrline = new CJocrLine;
	// 2...Set an instance of the pattern class to the line class (pattern already constructed elsewhere)
	//     Execution of mallocmemory is required
	pjocrline->msetpattern(pattern);
	// 3...Set an instance of the recognition class to the line class (precognize already constructed elsewhere)
	//     Execution of msetpattern, msetdict, and mallocmemory is required
	pjocrline->msetrecognize(precognize);
	// 4...Initialize the document
	// Call this whenever the image buffer for recognition changes
	typedef struct {
		unsigned char* 	top;		// Starting address of the image data
		short			width;		// Width of the image data (byte alignment, pixel units)
		short			height;		// Height of the image data (pixel units)
	} OCRBuffer;
	OCRBuffer aocrbuffer;
	aocrbuffer.top = ...;		// Buffer address
	aocrbuffer.width = ...;		// Buffer width (pixel units, multiple of 8)
	aocrbuffer.height = ...;	// Buffer height (pixel units)
	int i1 = pjocrline->msetdocument(&aocrbuffer);
	if(i1 < 0) {
		// MEMORY_SHORTAGE....Insufficient memory
		Display error message;
		delete pjocrline;
	}
    pjocrline->msetdpi(400);    // Resolution set to 400dpi
	Repeat line recognition. Call msetdocument when the image buffer for recognition changes.

	delete pjocrline;

Table of Contents


2.12 Line Recognition


The line recognition class only supports the coordinate system where the positive Y axis is pointing downwards. The coordinate system where the positive Y axis is pointing upwards is only supported by the paragraph recognition class.
    // Line settings
    OCRRect aocrrect;
    aocrrect.x1;   // Top-left X coordinate of the bounding rectangle of the line
    aocrrect.y1;   // Top-left Y coordinate of the bounding rectangle of the line
    aocrrect.x2;   // Bottom-right X coordinate of the bounding rectangle of the line
    aocrrect.y2;   // Bottom-right Y coordinate of the bounding rectangle of the line
#if Horizontal writing
    msetlineuser(&aocrrect,HORIZONTAL_LINE); // Horizontal writing
#else
    msetlineuser(&aocrrect,VERTICAL_LINE);   // Vertical writing
#endif
    // Line recognition
    i1 = pjocrline->mrecognize(CHAR_SET_ALL);
    if(i1 < 0) {Display error message;}
    else {
        int         resultnum;
        OCRResult   pocrresult[resultnum];
        // Get results
        i1 = pjocrline->mgetresult(resultnum,pocrresult);
        if(i1 < 0) {Display error message;}
    }

Table of Contents


2.13 Line Recognition Class Reference

The line recognition class supports only a coordinate system where the Y-axis positive direction is downward. The coordinate system where the Y-axis positive direction is upward is supported only by the paragraph recognition class.

  1. Initialization
  2. Document Settings
  3. Line Settings, Line Recognition, and Retrieving Recognition Results

Table of Contents


2.14 Language Processing Line Recognition Class Reference


The line recognition class only supports the coordinate system where the positive Y-axis is in the downward direction. The coordinate system where the positive Y-axis is in the upward direction is only supported by the paragraph recognition class.
Class NameCJocrLang
Header Filesocrdef.h
ocrco.h
cjocrline98.h
cjocrlang.h
errcode.h

Automatic correction is performed on the recognition results using linguistic knowledge. Up to 50% of misrecognition can be automatically corrected. A 20 megabyte language dictionary for general documents is included with ALOCR Ver.1.0 by default.
  1. Initialization

Table of Contents


2.15 Paragraph Recognition Class Reference

Class NameCJocrBlock
Header Fileocrdef.h
ocrco.h
cjocrblock.h
errcode.h

Recognizes a paragraph of text in either vertical or horizontal writing. It is possible to perform automatic correction using linguistic knowledge on the recognition result. It is possible to automatically correct up to 50% of misrecognitions. A language dictionary for general documents of up to 20 megabytes is included by default in ALOCR Ver.1.0.
The paragraph recognition class supports both the Y axis positive downward coordinate system and the Y axis positive upward coordinate system.

  1. Initialization
  2. Setting up the document
    Skew of the paragraph can be specified. It is possible to recognize italicized text limited to a single line.
  3. Setting up the paragraph, creating and obtaining normalized images
  4. Paragraph recognition, obtaining recognition result
  5. New version recognition method
  6. Deep learning compatible recognition method

Table of Contents


  • 3 sample program code
    Contents

    3.1 Sample Project for VC++ (Included)

    There are sample programs available in project file format that can be built with Visual C++ 4.2 or later.
    Usage
    1. Load a monochrome BMP file.
    2. Select "Recognition Mode" under the "Recognition" menu to display the "Recognition Result" dialog.
    3. When the "Recognition Result" dialog is displayed, drag the mouse while holding down the left button to enclose a string. The enclosed section will be recognized, and the result will be displayed in the "Recognition Result" dialog.
    4. Double-click on a character in the "Recognition Result" dialog to display the "Candidate Characters" dialog.
    5. Select a candidate and press the "Replace" button to replace the recognition result.
    6. Press the "Register" button to display the user dictionary registration dialog. Clicking the "Register" button again will register the pattern as a key for the specified character.
    7. Select "Character Type Setting" under the "Recognition" menu to change the target character type for recognition.
    8. Select "User Dictionary Reference" under the "Recognition" menu to reference or delete the content of the user dictionary.

    For more details about the program, please refer to the comments in the source file.

    Contents


    manual homepage

    user's manual