Document Settings
Set the document for performing line recognition. Also allocate memory based on the size of the document.
// Initialize the document
int msetdocument(OCRBuffer* apocrbuffer);
Input
OCRBuffer* apocrbuffer;
top...buffer address
width...buffer width (in pixels, multiples of 8)
height...buffer height (in pixels)
Return
0.................Normal completion
MEMORY_SHORTAGE...Insufficient memory
// Set the resolution
void msetdpi(int adpi);
Input
int adpi; Resolution
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"
...
....
// Create the pattern class
CJocrPattern* pattern = new CJocrPattern;
int ret = pattern->mallocmemory();
if(ret < 0) {
printf("Pattern class memory allocation error");
delete pattern;
exit(1);
}
// Create the 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 the single character recognition class
CJocrRecognize* precognize = new CJocrRecognize;
precognize->msetpatter(pattern);
precognize->msetdict(pjocrdict);
// Initialize the single character recognition class
ret = precognize->mallocmemory();
if(ret < 0) {
printf("Error");
delete precognize;
delete pjocrdict;
delete pattern;
exit(1);
}
// Create the line recognition class
CJocrLine* pjocrline = new CJocrLine;
pjocrline->msetpatter(pattern);
pjocrline->msetrecognize(precognize);
// Set the document
OCRBuffer ocrbuffer;
ocrbuffer.top = gbuffer1;
ocrbuffer.width = 1024; // Document width (in pixels)
ocrbuffer.height = 1024; // Document height (in pixels)
ret = pjocrline->msetdocument(&ocrbuffer);
if(ret < 0) {
printf("Error");
}
pjocrline->msetdpi(400); // Resolution: 400 dpi
....
...
..
// Set another document
ocrbuffer.top = gbuffer2;
ocrbuffer.width = 2048; // Document width (in pixels)
ocrbuffer.height = 1024; // Document height (in pixels)
ret = pjocrline->msetdocument(&ocrbuffer);
if(ret < 0) {
printf("Error");
}
pjocrline->msetdpi(300); // Resolution: 300 dpi
....
...
..
delete pjocrline;
delete precognize;
delete pjocrdict;
delete pattern;