Row Settings, Row Recognition, and Obtaining Recognition Results
Execute row recognition using an instance of the row recognition class
// Row settings
int msetline(OCRRect* pocrrect,unsigned char alinedirection);
Input
OCRRect* pocrrect; Row rectangle
unsigned char alinedirection; Row direction
HORIZONTAL_LINE.....Vertical writing
VERTICAL_LINE.......Horizontal writing
Return value
0.................Normal termination
MEMORY_SHORTAGE...Insufficient memory
-1................An error has occurred in the target image for recognition (post-processing is possible)
-2................The target image for recognition is too small or the tilt of the character string is too large (post-processing is not possible)
// Use mserlineuser if pocrrect is not an enclosing rectangle but contains spaces
int msetlineuser(OCRRect* pocrrect,unsigned char alinedirection);
Input
OCRRect* pocrrect; Row rectangle
unsigned char alinedirection; Row direction
HORIZONTAL_LINE.....Vertical writing
VERTICAL_LINE.......Horizontal writing
Return value
0.................Normal termination
MEMORY_SHORTAGE...Insufficient memory
-1................An error has occurred in the target image for recognition (post-processing is possible)
-2................The target image for recognition is too small or the tilt of the character string is too large (post-processing is not possible)
// Row recognition
int mrecognize(unsigned long afilter);
Input
unsigned long afilter; Character type filter
Characters other than those specified by afilter will not be included in the result
Recognition accuracy and speed will also increase
Return value
0.................Normal termination
MEMORY_SHORTAGE...Insufficient memory
// Obtaining recognition results
int mgetresult(int& resultnum,OCRResult* pocrresult);
Input
int& resultnum; Size of OCRResult structure array
OCRResult* pocrresult; OCRResult structure array
Output
int& resultnum; Number of elements in the result array
OCRResult* pocrresult; OCRResult structure array
Return value
0...................Normal termination
BUFFER_OVERFLOW.....Buffer overflow
In this case, the actual result is not included,
but the number of elements required for the structure array is returned to resultnum
※:Setting pocrresult as NULL and calling will set the number of recognition results to resultnum.
When you only want to obtain the number of recognition results, set NULL as the second argument and call.
Example
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrstock.h"
#include "cjocrdict98.h"
#include "cjocrpat98.h"
#include "cjocrrec98.h"
#include "cjocrline98.h"
#include "errcode.h"
...
....
// Assume that the initialization of the row recognition class has been completed
// Pointer to the instance is pjocrline
// Row settings
OCRRect ocrrect;
ocrrect.x1 = 100;
ocrrect.y1 = 200;
ocrrect.x1 = 300;
ocrrect.y1 = 250;
pjocrline->msetlineuser(&ocrrect,HOROZONTAL_LINE);
// Row recognition
int i1 = pjocrline->mrecognize(CHAR_SET_ALL);
if(i1 < 0) {
printf("Recognition error");
}
// Obtaining recognition results
int resultnum = 128;
OCRResult ocrresult[128];
i1 = pjocrline->mgetresult(resultnum,ocrresult);
if(i1 < 0) {
printf("Recognition error");
}
// Interpretation of the results
//
// ocrresult[0].cand[0].code is the recognition result for the first character
// ocrresult[1].cand[0].code is the recognition result for the second character
// ocrresult[0].cand[1].code is the second candidate for the first character
// ....