Feature Calculation in Pattern Class
Initialize the pattern class and calculate the features.
int mallocmemory();
Return Value
0.................Normal completion
MEMORY_SHORTAGE...Insufficient memory
void mcalcall(OCRBuffer* pocrbuffer,OCRRect* prect,int background);
Input
OCRBuffer aocrbuffer;
top......Address of the image buffer
width ...Width of the image buffer (byte boundary, in pixels)
height...Height of the image buffer (in pixels)
OCRRect arect;
x1...Top left X-coordinate of the pattern
y1...Top left Y-coordinate of the pattern
x2...Bottom right X-coordinate of the pattern
y2...Bottom right Y-coordinate of the pattern
int background;
0...Background is bit 0
1...Background is bit 1
Example
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrpat98.h"
#include "errcode.h"
...
....
CJocrPattern* pattern = new CJocrPattern;
ret = pattern->mallocmemory();
if(ret < 0) {
printf("Pattern class memory allocation error");
}
else {
OCRBuffer ocrbuffer;
OCRRect ocrrect;
ocrbuffer.top = gbuffer; // 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;
// Calculate the features
pattern->mcalcall(&ocrbuffer,&ocrrect,0); // Background is set to 0
}
delete pattern