Document Settings
Set the target document for paragraph recognition. No memory allocation is performed.
// Initialize document
// Set document settings
void msetdocument(unsigned char* data,int width,int height);
void msetdocument(unsigned char* data,int width,int scanlinesize,int height);
Input
unsigned char* data; // Address of the document image
int width; // Width of the document image (in pixels)
int scanlinesize; // Number of bytes per line
int height; // Height of the document image (in pixels)
// Set resolution
void msetdpi(int dpi);
Input
int dpi; // Resolution
// Set coordinate system
void msetaxis(int axis);
Input
int axis; // Coordinate system 0...Positive Y-axis is downward (default) / 1...Positive Y-axis is upward
// Set skew
void msetskew(double skew);
Input
double skew; // Skew angle in radians
// Normal italic is positive, reverse skew is also possible
Example
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrstock.h"
#include "cjocrdict98.h"
#include "cjocrpat98.h"
#include "cjocrrec98.h"
#include "cjocrline98.h"
#include "cjocrlang.h"
#include "cjocrblock.h"
#include "errcode.h"
...
....
// Create pattern class
CJocrPattern* pattern = new CJocrPattern;
int ret = pattern->mallocmemory();
if(ret < 0) {
printf("Pattern class memory allocation error");
delete pattern;
exit(1);
}
// Create dictionary class
CJocrDict* pjocrdict = new CJocrDict;
pjocrdict->msetsystemdict("c:\\dic\\feature\\system");
pjocrdict->msetsystemdict("c:\\dic\\feature\\systemfat");
pjocrdict->msetuserdict("c:\\dic\\feature\\user");
ret = pjocrdict->mloaddict();
if(ret < 0) {
printf("Error");
delete pjocrdict;
delete pattern;
exit(1);
}
// Create character recognition class
CJocrRecognize* precognize = new CJocrRecognize;
precognize->msetpatter(pattern);
precognize->msetdict(pjocrdict);
// Initialize character recognition class
ret = precognize->mallocmemory();
if(ret < 0) {
printf("Error");
delete precognize;
delete pjocrdict;
delete pattern;
exit(1);
}
// Create line recognition class with language processing
CJocrLang* pjocrlang = new CJocrLang;
pjocrlang->msetpatter(pattern);
pjocrlang->msetrecognize(precognize);
// Create paragraph recognition class
CJocrBlock* pjocrblock = new CJocrBlock;
pjocrblock->msetlang(pjocrlang);
pjocrblock->msetprocess(PREPROCESS_INSIDE); // Exclude primitives that touch the frame
// Set the document
pjocrblock->msetdocument(mdata,mwidth,mheight);
pjocrblock->msetdpi(400); // 400 dpi resolution
....
...
..
delete pjocrblock;
delete pjocrlang;
delete precognize;
delete pjocrdict;
delete pattern;