Registration
Register a record in the user dictionary. Set the pattern image itself to an instance of the pattern class, calculate the feature vector of the pattern, and then call the registration function with that instance as an argument. In order to register the difference between the user dictionary and the system dictionary, the dictionary class to be registered needs to load and initialize the system dictionary just like regular recognition.
int mput(char* akey,CJocrPattern* pattern);
Input
char* akey; Registration key
CJocrPattern* pattern; Pattern to be registered
Return value
0.....Normal termination
Negative numbers....FATAL_ERROR........Fatal error
FILE_SEEK_ERROR....File seek error
FILE_WRITE_ERROR...File write error
Example
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrstock.h"
#include "cjocrdict98.h"
#include "errcode.h"
...
....
CJocrDict* pjocrdict = new CJocrDict;
pjocrdict->msetsystemdict("c:\\dic\\feature\\system");
pjocrdict->msetsystemdict("c:\\dic\\feature\\systemfat");
pjocrdict->msetuserdict("c:\\dic\\feature\\user");
int ret = pjocrdict->mloaddict();
if(ret < 0) {
printf("Error");
delete pjocrdict;
exit(0);
}
CJocrPattern* pattern = new CJocrPattern; // Pattern to be registered
ret = pattern->mallocmemory();
if(ret < 0) {
printf("Error");
}
else {
OCRBuffer ocrbuffer;
OCRRect ocrrect;
ocrbuffer.top = gbuffer; // Start address of the image buffer
ocrbuffer.width = 1024; // Width of the image buffer (pixels)
ocrbuffer.height = 1024; // Height of the image buffer (pixels)
ocrrect.x1 = 100;
ocrrect.y1 = 100;
ocrrect.x2 = 300;
ocrrect.y2 = 300;
pattern->mcalcall(&ocrbuffer,&ocrrect,0); // Assume background is 0
ret = pattern->mput("漢",pattern);
if(ret < 0) {
printf("Registration Error");
}
}
delete pattern;
delete pjocrdict;